This is kind of a follow-up question for one I asked earlier. I have my function called tableRec. I added the level variable with the help of len_ny. However it seems the script still won't distinguish the levels of recursion, as the output doesn't print when the level 3 has been reached, and trackPoint remains as nil, causing an error.
module.tableRec = function(tab, func)
if type(tab) ~= "table" then return end
local level = 0;
for i, v in pairs(tab) do
level = level + 1
func(i, v, level)
module.tableRec(v, func, level)
end
end
functions.tableRec(module, function(a, b, lvl)
local trackPoint
if lvl == 3 then
print("level 3 of recursion has been reached")
trackPoint = b
end
if a == "Sensor" then
functions.tableRec(module, function(i, v, level)
local adjacentBlock
if level == 1 then adjacentBlock = v end
if i == "Sensor" then
if v == trackPoint.Sensor then
trackPoint.Adjacent = adjacentBlock
end
end
end)
elseif a == "PathOptions" then
for i = 1, #b do
b[i].Status = Instance.new("IntValue")
end
end
end)

2 comments
Would you consider indenting your code? It'd be much easier to read.
yes hold up