I came across this weird(frustrating, ILLOGICAL) error which totally makes me insane.
So.. What I'm trying to do is:
- Add a table in a table. The inserted table has an id value which is predetermined by another algorithm.
Then run the main table through table.sort and sort it by Y > Z values.
Then use the ID of each tile table to draw a map with depth.
This is my error. It makes no sense since this is the sorting code:
Code: Select all
table.sort(self.mapData, function(a, b) return a.y < b.y or a.z < b.z end)
Code: Select all
self.mapData = {}
for layer = 1, #mapIO.map.layers do
for pos = 1, mapIO.map.layers[layer].width * mapIO.map.layers[layer].height do
local id = mapIO.map.layers[layer].data[pos] -- a line I'll mention
if id ~= 0 then
-- x, y coordinates are being saved as iso coordinates
x, y = mapToIso(pos)
z = (layer - 1) / 2
table.insert(self.mapData, {id = id, x = x, y = y, z = z})
end
end
end
Line 63 adds the IDth quad to a spritesheet. It obviously errors since ERROR #2 THE VARIABLE ID IS 2049.
(I don't have a 2049th quad)
I NEVER SET THE GLOBAL VARIABLE ID IN MY CODE EVER BEFORE AND IT IS DESTOYING MY MENTAL HEALTH..
I also have no idea how it affects the table.sort function.
I'm attaching the love file at the bottom of the post so.. please give it a look and yeah.
Thank you for your help