-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempt to call method 'getX' (a nil value) #35
Comments
Ok, I figured out the first problem. I had to use node.x and node.y instead of node.getX() and node.getY(). Is the readme outdated? :O |
Remember to use the most recent stable build of Jumper and not the dev version. |
@Myll, first of all, thanks for the kind words, and for your interest. Concerning the first question, well, the README is not outdated. You are actually (I believe) using the newer syntax for the actual development version of this library, as @pancsoftware kindly pointed out. Instead, use the latest stable version (which is 1.8.1, at the moment, and the example given for this version.). As for the second question, you normally don't need to do such expensive things. Actually, Jumper resolves the collision map dynamically. You just have to init a pathfinder once, passing it your collision map. Later on, if you need to change node from walkable to unwalkable, or vice versa, just tweak the collision map data directly. For instance: local map = {
{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},
{0,0,0,0,0,0,0},
}
local Grid = require ('jumper.grid')
local Pathfinder = require ('jumper.pathfinder')
local walkable = 0
local myGrid = Grid(map)
local myFinder = Pathfinder(grid, 'ASTAR',walkable)
-- Need to change node at (x = 4,y = 1) behaviour
print(myGrid:isWalkableAt(4,1)) --> true
map[1][4] = 1 -- Change the collision map data for node(4,1) from "0" to "1"
print(myGrid:isWalkableAt(4,1)) --> false This is basically how it works. By changing the underlying collision map data, in case a value on this map no longer matches the initial "walkable" property given, Jumper considers the corresponding node as no longer walkable. PS/ Side note, it is advised in general not to use "/" in paths passed to require, but instead use dots ".". Slashes can cause problems on some specific systems, while dots will not. So better use this style: local Grid = require ("jumper.grid") -- The grid class
local Pathfinder = require ("jumper.pathfinder") -- The pathfinder lass You might have noticed this is the style I always use in the examples I give in all my READMEs. Hope all of this helps. Let me know how it goes anyway. |
Hi @Myll, |
Got it, thanks.
|
Hi, sorry if this is the wrong place to ask for help; I couldn't find a forum to post to. Thanks for the amazing library you built together! I'm working on implementing it in Dota 2 modding. I have a couple questions.
1: The program is finding a path, but when it tries to execute this line:
it gives me an error: "attempt to call method 'getX' (a nil value)".
When I comment out that line and let the for loop run, here is each node's table printed out: http://pastebin.com/wUTbn3NN
2: What are you required to do when you need to change nodes from walkable to unwalkable and vice versa? At the moment I'm changing values in the collision map to 1 (without searching), and then running this code:
However this seems quite expensive, and I even get small lag spikes everytime this executes.
Thanks!
The text was updated successfully, but these errors were encountered: