The cellmap could example look like this if it was 3x3
Code: Select all
--[[
111
101 --# The visual representation of the cellmap
111
--]]
--# The cellmap uses x and y indexes ( cellmap[x][y] = some_id )
local cellmap = {
[1][1] = "1";
[1][2] = "1";
[1][3] = "1";
[2][1] = "1";
[2][2] = "0";
[2][3] = "1";
[3][1] = "1";
[3][2] = "1";
[3][3] = "1";
}
Code: Select all
cellmap = scale( cellmap, 2 )
--[[
111111
111111
110011 --# Since it was scaled by 2 it doubled in size
110011
111111
111111
--]]
Here's the function I use for scaling, when using the scaling function it messes up, otherwise it works as expected.
Code: Select all
function World:scale_cellmap( cellmap, scale )
local new_cellmap = {}
for x = 1, #cellmap do
for y = 1, #cellmap[x] do
for w = 1, scale do
local index = #new_cellmap + 1
new_cellmap[ index ] = {}
for h = 1, scale do
new_cellmap[ index ][ #new_cellmap[index] + 1 ] = cellmap[x][y]
end
end
end
end
return new_cellmap
end