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

Lua Create IF Z=?

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

Not work on 0.4
Code:
[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>
 
Code:
local pos = getCreaturePosition(cid)
if pos.z == 7 then
getCreaturePosition(cid) typically returns x,y,z,stackpos.
Just callback the z position only.
 
Back
Top