• 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!

isWalkable

This is pretty close, maybe you can get a good understanding and edit it to fit your needs... Not my creation btw, if I remember right I got this from zbizu....


Code:
function Position:isPathable(checkpz, checkcreature)
local tile = Tile(self)
    if not tile then
        return false
    end

    if checkpz then
        if tile:hasFlag(TILESTATE_PROTECTIONZONE) then
            return false
        end
    end
   
    if checkcreature then
        if tile:getTopCreature() then
            return false
        end
    end
   
    if tile:hasFlag(TILESTATE_MAGICFIELD) then
       
    end
   
    return (not tile:hasFlag(TILESTATE_BLOCKSOLID))
end
 
the function is actually inside other function in the Position lib of TFS, y'know

add at the bottom of position.lua
Code:
function Position:isWalkable()
    local tile = Tile(self)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, tile:getItemCount() do
        local item = items[i]
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end
 
Back
Top