Sintaxe: isWalkable(pos)
Descrição: A função retorna se você pode andar na posição "pos".
Requerimentos: Lua 5.1+ e um OTServer.
Função:
function isWalkable(pos)
local wall0 = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})
local wall1 = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})
local wall2 = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=2})
local creature = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=253})
if wall0.uid ~= 0 and hasProperty(wall0.uid, 3) == FALSE and hasProperty(wall0.uid, 7) == FALSE then
if wall1.uid == 0 or (hasProperty(wall1.uid, 3) == FALSE and hasProperty(wall1.uid, 7) == FALSE) then
if wall2.uid == 0 or (hasProperty(wall2.uid, 3) == FALSE and hasProperty(wall2.uid, 7) == FALSE) then
if creature.uid == 0 then
return TRUE
end
end
end
end
return FALSE
end
Comentários adicionais: Quando há uma criatura na posição em que você faz a checagem é retornado um erro mas não acontece nada de errado.
É retornado TRUE se você puder andar em "pos", caso contrário é retornado FALSE.
Pra quem não sabe adicionar funções num OTServer copie a função e cole depois do último end que está no global.lua