Last active
August 29, 2015 14:05
-
-
Save britzl/015ee0633c9b821730c5 to your computer and use it in GitHub Desktop.
Dump contents of global table
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 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