Hey Everyone
I am trying to save and load a 2D array I created. I am using the JSON library and I can get it to save my table fine but just can’t figure out how to load it.
Here is my code, this is my 2D array with 1’s and 0’s
grid = {} --Grid array
– build screen now –
for x = 0, across do
grid[x] = {}
for y = 0, down do
local probability = math.random(0,10)
if probability <= stonefrequency then
grid[x][y] = 1 —Stone
else
grid[x][y] = 0 --Dirt
end
end
end
Here is my save call
loadsave.saveTable(grid, “grid.json”)
Now I exit my app and reopen it loading my JSON data
gridsave = loadsave.loadTable(“grid.json”)
I just don’t know how to feed my loaded data into a new 2d grid. I have gotten it to work if I do the save and load all in one scene. But once I close my app and try to build the array with saved data it doesn’t work.
Any help would be great.
