I generate a voxel space and set each point to a value that needs to be saved. I use a table for this. But when I exceed the grid size value of more than 300
(27,000,000 voxels in table), the loop starts lagging and throws a wait error.
local Table = {}
for x = 0, 300, 1 do task.wait()
for y = 0, 300, 1 do
for z = 0, 300, 1 do
Table[VectorStringName] = {...}
end
end
end
By the end of the cycle, it starts running slower and slower, and then a waiting error pops up. What can be done to optimize such huge arrays?
best thing to do is instead of having one huge table, is to use chunks and split the tables up
i had a voxel system and what i did was for every new chuck i added a folder and placed a module inside of the folder and all my voxel data for that chunk went inside of that module
I started doing it. But it seems that my knowledge wasn’t that good, and I just divided them into fragments and put them in one table. XD
Thank you, I understand that it is best to use a separate script module to store the table.