Page 1 of 1

Pathfind problem!

Posted: Thu Jul 16, 2015 12:55 am
by tetsuken
Hello guys i'm here again with some problems, if some one can help i will apreciate, thanks in advance.

The problema consist of table index nil,

Code: Select all

monsterlist[turnCounter].path = CalcPath(CalcMoves(collisionmap, monsterlist[turnCounter].cx, monsterlist[turnCounter].cy, monsterlist[turnCounter].target.x, monsterlist[turnCounter].target.y))
      steplist = monsterlist[turnCounter].path
as you can see i trying to save table with the points of he path created on CalcPath() and store on steplist, but when i refer to steplist i get index nil.
The problem is, when i draw the point of the path using direct the monsterlist.path everything work well (code bellow)

Code: Select all

if monsterlist[turnCounter].path ~= nil then
  love.graphics.print(monsterlist[turnCounter].path[2].x..','..monsterlist[turnCounter].path[2].y,(monsterlist[turnCounter].cx*32),(monsterlist[turnCounter].cy*32))
  end
But when i try a simple reposition of the monster based on the path it returns nil (code below)

Code: Select all

if monsterlist[turnCounter].state == 'chacing' then
    monsterlist[turnCounter].dx = monsterlist[turnCounter].path[2].x
    monsterlist[turnCounter].dy = monsterlist[turnCounter].path[2].y
  end
After try this ad not work i try store the monsterlist.path in steplist ... to the refer to steps on steplist but it also give me index nil

i need some help here, i cant understand why i can draw correct the points of the way ... and get nil when i try give the new position to player ... since i can see cleary the way made by the points when run the program.

ty for any help