No, thanks.You need help using structs?
But i have another problem.
I did it. Now my map splits into chunks, writes to files and can load.
And my function have a memory leak.
Code: Select all
--map - 1000x1000x1, chunk_size - 100
function map_splitOnChunks(map, chunk_size)
local mapsW, mapsH = 1000/chunk_size, 1000/chunk_size
local lastX, lastY = 1, 1
local pus = 0
for a = 1, mapsW do
for b = 1, mapsH do
local chunk = {}
local CS_X, CS_Y = chunk_size, chunk_size
if a ~= 1 then
lastX = chunk_size*(a-1)
CS_X = chunk_size+lastX
elseif a == 1 then
lastX = 1
CS_X = chunk_size
end
if b ~= 1 then
lastY = chunk_size*(b-1)
CS_Y = chunk_size+lastY
elseif b == 1 then
lastY = 1
CS_Y = chunk_size
end
for x = lastX, CS_X do
chunk[x] = {}
for y = lastY, CS_Y do
chunk[x][y] = {}
for z = 1, 1 do
chunk[x][y][z] = map[x][y][z]
end
end
end
chunk = nil
collectgarbage()
end
end
collectgarbage()
end
Otherwise, memory is ~220kb
I found source. This is:
Code: Select all
for a = 1, mapsW do
for b = 1, mapsH do
end
end