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

TFS 1.X+ getNextPosition guidance required

DemShion

New Member
Joined
Apr 8, 2013
Messages
82
Reaction score
1
Location
Mexico
Hello im trying to use the getNextPosition function without success, heres my code:

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.
 
Back
Top