Jumper Pathfinding node:getX problem

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

Jumper Pathfinding node:getX problem

Post by NoAim91 » Mon Feb 27, 2017 10:50 am

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.

User avatar
4aiman
Party member
Posts: 251
Joined: Sat Jan 16, 2016 10:30 am

Re: Jumper Pathfinding node:getX problem

Post by 4aiman » Mon Feb 27, 2017 11:35 am

Hi!
Are you sure you haven't transposed the map of the level? That would be a common error.

NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

Re: Jumper Pathfinding node:getX problem

Post by NoAim91 » Mon Feb 27, 2017 11:43 am

I have copy pasted all the stuff, including the map example. I think the map is transposed.

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

User avatar
4aiman
Party member
Posts: 251
Joined: Sat Jan 16, 2016 10:30 am

Re: Jumper Pathfinding node:getX problem

Post by 4aiman » Mon Feb 27, 2017 5:02 pm

That's strange. The example works just fine for me.

NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

Re: Jumper Pathfinding node:getX problem

Post by NoAim91 » Mon Feb 27, 2017 6:22 pm

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.

User avatar
4aiman
Party member
Posts: 251
Joined: Sat Jan 16, 2016 10:30 am

Re: Jumper Pathfinding node:getX problem

Post by 4aiman » Mon Feb 27, 2017 8:18 pm

Really-really ;)
I've used Jumper in this little game: https://4aiman.itch.io/viwus-attawk, maybe that will help you with the library?

User avatar
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

Post by Roland_Yonaba » Mon Feb 27, 2017 9:14 pm

NoAim, please go to the latest stable version of Jumper here. Conveniently, you will find a small tutorial for you to get your hands-on quickly on the library. Have fun with Jumper.

User avatar
4aiman
Party member
Posts: 251
Joined: Sat Jan 16, 2016 10:30 am

Re: Jumper Pathfinding node:getX problem

Post by 4aiman » Tue Feb 28, 2017 3:27 am

@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?

Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests