function isAtPositionZ(creature, z)
return creature:getPosition().z == z
end
local creature = Creature(cid)
if isAtPositionZ(creature, 7) then
-- Do stuff.
end
This is how I would do it in TFS 1.x.
Code:function isAtPositionZ(creature, z) return creature:getPosition().z == z end local creature = Creature(cid) if isAtPositionZ(creature, 7) then -- Do stuff. end
[7:43:51.144] [Error - NpcScript Interface]
[7:43:51.144] data/npc/scripts/spellseller.lua:onCreatureSay
[7:43:51.144] Description:
[7:43:51.144] data/npc/scripts/spellseller.lua:114: attempt to call global 'Creature' (a nil value)
[7:43:51.144] stack traceback:
[7:43:51.144] data/npc/scripts/spellseller.lua:114: in function 'callback'
[7:43:51.144] data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[7:43:51.144] data/npc/scripts/spellseller.lua:103: in function <data/npc/scripts/spellseller.lua:103>
getCreaturePosition(cid) typically returns x,y,z,stackpos.Code:local pos = getCreaturePosition(cid) if pos.z == 7 then
Just callback the z position only.