Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if currentMap.monsterList[gpMode.Mon].npcAction == "find" then
- print ("FINDING!!!!!!!!!!!")
- local startx = gpMode.Mx
- local starty = gpMode.My
- local endx = gpMode.playerX
- local endy = gpMode.playerY
- local myFinder = Pathfinder(grid, 'JPS', walkable)
- path = myFinder:getPath(startx, starty, endx, endy)
- if path == nil then
- print("PATH IS NIL! CLEARING VARS!")
- resetVars() -- resetting the movement holders in the event of a non-viable path
- else
- if path then
- successfulMove = true
- print(('Path found! Length: %.2f'):format(path:getLength()))
- for node, count in path:nodes() do
- print(('Step: %d - x: %d - y: %d'):format(count, node:getX(), node:getY()))
- print(node:getX())
- print(node:getY())
- setX[#setX+1] = node:getX() -- populating coordinate table on each movement
- setY[#setY+1] = node:getY() -- populating coordinate table on each movement
- cellb[node:getY()][node:getX()].alpha = .8 -- see the path you've chosen!
- moveCount = moveCount+1
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement