Skip to content

Instantly share code, notes, and snippets.

@britzl
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save britzl/015ee0633c9b821730c5 to your computer and use it in GitHub Desktop.
Save britzl/015ee0633c9b821730c5 to your computer and use it in GitHub Desktop.
Dump contents of global table
local function gdump()
local function dump_table(t, indentation)
indentation = indentation or ""
local table_model = {}
for k,v in pairs(t) do
table_model[type(v)] = table_model[type(v)] or {}
table_model[type(v)][k] = v
end
for type,_ in pairs(table_model) do
print(indentation .. type .. ":")
for k,v in pairs(table_model[type]) do
print(indentation .. indentation .. k .. " [" .. tostring(v) .. "]")
end
end
end
for k,v in pairs(_G) do
local is_table = type(v) == "table"
if is_table then
print(k .. " [table]:")
dump_table(v, " ")
else
print(k .. " [" .. tostring(v) .. "]")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment