Skip to content

Instantly share code, notes, and snippets.

@polymorphm
Last active August 29, 2015 14:08
Show Gist options
  • Save polymorphm/bc4b40f1c20fbbb21681 to your computer and use it in GitHub Desktop.
Save polymorphm/bc4b40f1c20fbbb21681 to your computer and use it in GitHub Desktop.
dump table (in lua)
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