• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

About Doors

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
How to check if one sqm has a door? I want to prevent players from using an item if it is on top of the door.

tfs 1.2
 
Solution
LUA:
function Tile.hasDoor(self)
    local items = self:getItems()
    for i = 1, #items do -- loop through all items on the tile
        if items[i]:getType():isDoor() then -- check if current item in the stack is a door type
            return true
        end
    end
    return false -- return false by default if no door was found
end
you can use something like this
example:
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if Tile(toPosition):hasDoor() then
        player:sendCancelMessage("You cannot use this when there is a door on the tile.")
        return true
    end
    -- do something special when there isn't a door on the tile
    return true
end
LUA:
function Tile.hasDoor(self)
    local items = self:getItems()
    for i = 1, #items do -- loop through all items on the tile
        if items[i]:getType():isDoor() then -- check if current item in the stack is a door type
            return true
        end
    end
    return false -- return false by default if no door was found
end
you can use something like this
example:
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if Tile(toPosition):hasDoor() then
        player:sendCancelMessage("You cannot use this when there is a door on the tile.")
        return true
    end
    -- do something special when there isn't a door on the tile
    return true
end
 
Solution
Back
Top