# is the length operator, it gets the character amount of string and the amount of array indexed values in a table.
local TableLength = function(tab,recurse)
local len = 0
function search(t)
if type(t) == "table" then
for i,v in next, t do
len = len + 1
if recurse and type(recurse) == "boolean" then
search(v)
end
end
end
end
search(tab)
return len
end
local tabl = {hi = 9,p = {1,34,{hahaha = 0}}}
print(TableLength(tabl)) --> 2
print(TableLength(tabl,true)) --> 6
Which may seem a bit weird but you must remember that the table(s) inside the table are still values.
I script -~ chimmihc |