Created
March 2, 2016 17:55
-
-
Save Shujito/e8f6947057ad3f87a2ba to your computer and use it in GitHub Desktop.
Recurse a lua table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function recurse(t,lvl) | |
lvl = lvl or 0 | |
for k,v in pairs(t) do | |
print( string.rep(' ',lvl) .. k) | |
if type(v) == 'table' then | |
recurse(v,lvl+1) | |
else | |
print( string.rep(' ',lvl) .. ' ' .. type(v) .. ':') | |
print( string.rep(' ',lvl) .. ' ' .. tostring(v)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment