I am about to implement some pathfinding in a game I am working on using jumper, and when I looked inside the .lua files generated by tiled I saw that they have an array that seems convertable or usable for this. When i try accessing a layers data field I was expecting this array to be returned but instead I get a table that contains a table, that contains nil
local layer = gameMap.layers["PathFinding"]
print (layer.data[1])
print (layer.data[1][1])
print (layer.data[1][1][1])
I first get a table, which I was assuming might mean its a 2d array, so then I tried indexing further and got another table?, and the last index is just nil? I must be misunderstanding how to access this mapping. I just want to generate a 2d array for jumper based off the tile ids 2 and 3 (2 being obstacle) (3 being walkable).
I've not used STI before but had a quick gander at the source code and it's building a fairly complex representation of the map under the hood. You're right that layer.data is a 2D array, but the value stored there is a table with a load of metadata about the tile there. From what I can gather the field "gid" is the original ID as it appears in the file generated by Tiled so you could do something like this: