Lua:
-- Returns the top item on a tile.
function getTopItem(pos)
pos.stackpos = 1 + getTopCreature(pos).itemid
return getTileThingByPos(pos)
end
-- Teleport a creature with effects, invisible players will not show effects!
function doTeleportCreature(cid, pos, pushmove)
if(not isCreature(cid)) then
return FALSE
end
if(not isPlayerGhost(cid)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
end
doTeleportThing(cid, pos, pushmove)
return TRUE
end
-- Check whether a position is free (for a player to walk on)... can't remember if it works tho :D
function isPositionFree(pos)
local thing = getTopCreature(pos)
if isCreature(thing.uid) == FALSE then
pos.stackpos = 0
thing = getThingfromPos(pos)
if thing.uid > 0 then
while hasProperty(thing.uid, CONST_PROP_BLOCKINGANDNOTMOVEABLE) == FALSE do
pos.stackpos = pos.stackpos + 1
thing = getThingfromPos(pos)
if thing.uid == FALSE then
return TRUE
end
end
end
end
return FALSE
end
Last edited: