Hello im trying to use the getNextPosition function without success, heres my code:
and the msg that prints out to the console is the following:
also i get the following error in the console:
So my question is, why is "local posAux = creature:getPosition():getNextPosition(pathToObj[index])" evaluating to nil? thanks in advance.
Code:
function doCharge(cid, targetcid, index)
local creature = Creature(cid)
local target = Creature(targetcid)
local pathToObj = creature:getPathTo(target:getPosition(), 0, 1, true, true)
if pathToObj ~= false then
if creature then
while pathToObj[index] ~= nil do
print(pathToObj[index])
local posAux = creature:getPosition():getNextPosition(pathToObj[index])
print(posAux)
addEvent(function()
creature:teleportTo(posAux, true)
end, 200)
index = index + 1
end
end
end
end
and the msg that prints out to the console is the following:
Code:
2
nil
2
nil
also i get the following error in the console:
Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
attempt to index a nil value
stack traceback:
[C]: at 0x7ff6709f75a0
[C]: in function 'teleportTo'
data/spells/scripts/attack/knight_charge_1.lua:25: in function <data/spells/scripts/attack/knight_charge_1.lua:24>
So my question is, why is "local posAux = creature:getPosition():getNextPosition(pathToObj[index])" evaluating to nil? thanks in advance.