Last active
August 29, 2015 14:08
-
-
Save polymorphm/bc4b40f1c20fbbb21681 to your computer and use it in GitHub Desktop.
dump table (in lua)
This file contains hidden or 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 tprint(tbl, indent, depth) | |
if indent == nil then indent = 0 end | |
if depth == nil then depth = 4 end | |
for k, v in g.pairs(tbl) do | |
local formatting = g.string.rep(' ', indent) .. g.tostring(k) .. ': ' | |
if g.type(v) == 'table' then | |
if indent < depth then | |
g.print(formatting) | |
tprint(v, indent + 1) | |
else | |
g.print(formatting .. '...') | |
end | |
else | |
g.print(formatting .. '(' .. g.type(v) .. ') ' .. g.tostring(v)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment