I know, maybe a not WoWInterface related question, but I need to manage my addon profile table.
This is my custom function:
Lua Code:
function scope(tbl, depth)
if depth > 0 then
for k, v in pairs(tbl) do
if type(v) ~= 'table' then
print(v)
else
scope(v, depth - 1)
end
end
end
end
This is the usage: let
Lua Code:
stuff = {
fruit = {
yellow = {
"Banana"
}, -- depth = 3
red = {
"Apple"
} -- depth = 3
},
city = {
"Toronto"
}, -- depth = 2
name = {
"Claudia"
} -- depth = 2
}
returns
Otherwise,
returns
Code:
Banana
Apple
Toronto
Claudia
This code works fine for me. Any advice on how to improve it? Maybe insert some code that displays
if, as here, I specify depth value of 1 or a number greater than 3 (the depth of the table).