Hallo again,
I try since 3 days to implement a Pathfinding libary and i get frustred now. :-(
I copy/paste the Jumper example and it doesn´t work. The Error is "attempt to call method 'getX' (a nil value)
I don´t know how to get the path information out of the method.
Thanks for help again.
Jumper Pathfinding node:getX problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Jumper Pathfinding node:getX problem
Hi!
Are you sure you haven't transposed the map of the level? That would be a common error.
Are you sure you haven't transposed the map of the level? That would be a common error.
Re: Jumper Pathfinding node:getX problem
I have copy pasted all the stuff, including the map example. I think the map is transposed.
https://github.com/Yonaba/Jumper
https://github.com/Yonaba/Jumper
Code: Select all
-- Usage Example
-- First, set a collision map
local map = {
{0,1,0,1,0},
{0,1,0,1,0},
{0,1,1,1,0},
{0,0,0,0,0},
}
-- Value for walkable tiles
local walkable = 0
-- Library setup
local Grid = require ("jumper.grid") -- The grid class
local Pathfinder = require ("jumper.pathfinder") -- The pathfinder lass
-- Creates a grid object
local grid = Grid(map)
-- Creates a pathfinder object using Jump Point Search
local myFinder = Pathfinder(grid, 'JPS', walkable)
-- Define start and goal locations coordinates
local startx, starty = 1,1
local endx, endy = 5,1
-- Calculates the path, and its length
local path = myFinder:getPath(startx, starty, endx, endy)
if path then
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()))
end
end
Re: Jumper Pathfinding node:getX problem
That's strange. The example works just fine for me.
Re: Jumper Pathfinding node:getX problem
realy? When I create a new folder with a main.lua and the code above. In the same folder I placed the jumper folder. Than I run the code and get the error.
Re: Jumper Pathfinding node:getX problem
Really-really
I've used Jumper in this little game: https://4aiman.itch.io/viwus-attawk, maybe that will help you with the library?
I've used Jumper in this little game: https://4aiman.itch.io/viwus-attawk, maybe that will help you with the library?
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Jumper Pathfinding node:getX problem
@Roland_Yonaba
It is *very* strange that when clonning I'm getting tagged version you've mentioned and not master branch.
Even strangier ( ) is the fact that the commit a2be178 made on 3 Mar 2013 is better than commit df4eb22 made on 12 Apr 2015.
Maybe an update to the readme file (to tell people to go get a tagged revision) will be posibble?
It is *very* strange that when clonning I'm getting tagged version you've mentioned and not master branch.
Even strangier ( ) is the fact that the commit a2be178 made on 3 Mar 2013 is better than commit df4eb22 made on 12 Apr 2015.
Maybe an update to the readme file (to tell people to go get a tagged revision) will be posibble?
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 136 guests