local Jumper = require('Jumper.init')
-- A collision map : 0 for walkable tiles,
-- non-zero for unwalkable tiles
local map = {
{0,1,1,0},
{0,1,1,0},
{0,0,0,0},
}
local pather = Jumper(map,0) -- Inits our pathfinder
pather:setAutoFill(true) -- Turns on autoFill feature
local startX, startY = 1,1 -- starting node
local endX, endY = 4,1 --end node
local path, dist = pather:getPath(startX, startY, endX, endY) -- gets the path
-- Output it!
if path then
print(('From [%d,%d] to [%d,%d] : Length: %.2f'):format(startX, startY, endX, endY, dist))
table.foreach(path, function(i,node)
print(('Step %d: x = %d, y = %d'):format(i,node.x,node.y))
end)
else
print(('From [%d,%d] to [%d,%d] : No Path found!'):format(startX, startY, endX, endY))
end
main.lua is uploading.
Uploading finished.
From [1,1] to [4,1] : Length: 5.83
Step 1: x = 1, y = 1
Step 2: x = 1, y = 2
Step 3: x = 2, y = 3
Step 4: x = 3, y = 3
Step 5: x = 4, y = 2
Step 6: x = 4, y = 1
Loves: phongtt
Loves: atilim
Loves: atilim
Did you have it working ?atilim said:@Roland_Y Already started playing with it :) Your code contains some variables like _PACKAGE. I think they are related to Love2d, right? But there are only a few so it will be easy to adapt them.
Any progress so far? :)atilim said:@Magnusviri Currently if nobody creates a Gideros example project, I'm willing to create one.
local _path = (...):gsub("%.init", "") |
init.lua:24: attempt to index a nil value
stack traceback:
init.lua:24: in main chunk

-- In B.lua
local path = ...
from file1 file1
from folder1.file1 folder1.file1
print('From init.lua, path received from main.lua', ...)
local _path = (...):gsub("%.init", "")
return require (_path..'.jumper')
Uploading finished.
From init.lua, path received from main.lua
init.lua:25: attempt to index a nil value
stack traceback:
init.lua:25: in main chunk


Uploading finished.
init.lua:24: attempt to index a nil value
stack traceback:
init.lua:24: in main chunk
Uploading finished.
.\?.lua;C:\Program Files\Gideros\lua\?.lua;C:\Program Files\Gideros\lua\?\init.lua;C:\Program Files\Gideros\?.lua;C:\Program Files\Gideros\?\init.lua
Loves: atilim
Loves: ar2rsawseen
local map = {
{0,0,0},
{0,0,0},
{0,0,0},
}
local Jumper = require 'Jumper.init'
local walkable = 0
local pather = Jumper(map,walkable)
-- etc etc
map[2][1] = 1 -- Cell[1,2] becomes unpassablelocal Jumper = require 'Jumper.init'
local walkable = 0
local allowDiagonal = false
local heuristicName = 'MANHATTAN'
local autoFill = false
local postProcess = true
local pather = Jumper(map,walkable,allowDiagonal,heuristicName,autoFill,postProcess)It looks like you're new here. If you want to get involved, click one of these buttons!
ar2rsawseen
2657
OZApps
1301
techdojo
1235