Hello,
I get heavy lags after creating a big table in Lua. During the lags, nothing is editing the table in any way, at least in the lua code. The table is created and then it is left alone, until I press “R”, which creates objects and links them in that array. “T” will delete that table (for testing!). When deleting the table, the lags are away.
Something is doing stuff with that big table in every frame update. So, what is going on and how can I eliminate these lags?
The table is created that way.
local function initChunk(_c)
if _c.d == nil then
_c.d = {}
end
for bx = 1, 8, 1 do
if _c.d[bx] == nil then
_c.d[bx] = {}
end
local a = _c.d[bx]
for by = 1, 8, 1 do
if a[by] == nil then
a[by] = {}
end
local b = a[by]
for bz = 1, 8, 1 do
if b[bz] == nil then
b[bz] = {id = 0, obj = nil}
end
end
end
end
end
local function worldInit(_w)
local cxmax = 4;
local cymax = 4;
local czmax = 4;
for cx = 1, cxmax, 1 do
if _w[cx] == nil then
_w[cx] = {}
end
local a = _w[cx]
for cy = 1, cymax, 1 do
if a[cy] == nil then
a[cy] = {}
end
local b = a[cy]
for cz = 1, czmax, 1 do
if b[cz] == nil then
b[cz] = {}
initChunk(b[cz])
end
end
end
end
end
Edit: reworked the code, but has the same functionality as before.