Unitscan
Newcomer
- Joined
- Mar 25, 2022
- Messages
- 1
- Reaction score
- 0
I have this table
I would like to make it so that by calling the function
Otherwise, by calling the function
I know you have to use the recursive functions, but how?
Thanks in advance
Lua:
stuff = {
fruit = {
yellow = {
"Banana"
},
red = {
"Apple"
}
},
city = {
"Toronto"
},
name = {
"Claudia"
}
}
function scope(tbl,depth)
for k, v in pairs(tbl) do
-- my code here
end
end
I would like to make it so that by calling the function
scope(stuff, 2)
the output be
Code:
Toronto
Claudia
Otherwise, by calling the function
scope(stuff, 3)
the output be
Code:
Banana
Apple
I know you have to use the recursive functions, but how?
Thanks in advance