I know the algorithm to 'unflatten' the 1d array into a 2d + z-index:
var tileIndex = (z * section.height + y) * section.width + x;However, when using this:
Attempt 2:
Attempt 3:
Attempt 3a (same result as attempt #2):
Attempt 4:
I do not understand what I'm doing wrong.
var tileIndex = (z * section.height + y) * section.width + x;However, when using this:
$dataMap.data = section.data; // section.data contains the data from another map that I'm trying to paste into the current map, overwriting the old data$gameMap.setup($gameMap._mapId);Result: Nothing happens. I actually expected this solution to work.
Attempt 2:
for(var i=0; i<section.data.length; i++) { $dataMap.data = section.data; }$gameMap.setup($gameMap._mapId);Result:

So something is wrong regarding the x & y locations... But how is this code different compared to $dataMap.data = section.data; (if the maps are of equal size)... How can the result be different?

So something is wrong regarding the x & y locations... But how is this code different compared to $dataMap.data = section.data; (if the maps are of equal size)... How can the result be different?
Attempt 3:
var z = 1; for(var y=0; y<section.height; y++) { for(var x=0; x<section.width; x++) { var index = (z * section.height + y) * section.width + x; $dataMap.data[index] = section.data[index]; } }$gameMap.setup($gameMap._mapId); Result: Nothing happens.
Attempt 3a (same result as attempt #2):
Attempt 4:
$dataMap.data = [];$gameMap.setup($gameMap._mapId);Result: Nothing happens. So it seems the tiles are not refreshed just by calling the setup? Or atleast not properly because the old ones are still showing.
I do not understand what I'm doing wrong.
