Yeah, great bjorn! I have followed your advice to just create my own array / data instead of trying to custom code a C++ or python plugin.
Here is my script I made to convert something like this; (Could be for any amount of layers)
{
"data": [
[
[6, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 1, 0, 100, 101, 0],
[0, 0, 0, 1, 0, 0, 1, 0, 115, 116, 0],
[6, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
],
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]
]
}
This is the same type of DataSet used for play.treasurearena.com as well if you’re looking for awesome custom maps with collision and the 3d effect.
Here is the code in JavaScript:
MapData = {TILEDMAPJSONEXPORTDATAHERE}
var NewMap = {};
NewMap.data = []; // Create Data key and set it as an array;
var num_layers = MapData.layers.length;
var map_width = MapData.width;
var map_height = MapData.height;
function listToMatrix(list, elementsPerSubArray) {
var matrix = [], i, k;
for (i = 0, k = -1; i < list.length; i++) {
if (i % elementsPerSubArray === 0) {
k++;
matrix[k] = [];
}
matrix[k].push(list[i]);
}
return matrix;
}
var newData = [];
for(var i = 0; i < num_layers; i++){
newData.push(listToMatrix(MapData.layers[i].data, map_width));
}
NewMap.data = newData; // Set the data property to grab the array matrix we built.
console.log(JSON.stringify(NewMap));
And here is the working demo with the tiled map export: https://jsfiddle.net/e5yowcap/3/
- Make sure you export as json format as well.
Thanks to bjorn with the idea, and also if anyone see’s this thread you’re welcome!!