Created
June 21, 2015 20:50
-
-
Save sofar/41d1e70893f16d457ff1 to your computer and use it in GitHub Desktop.
init.lua - dump lua global table with table element size estimate
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
minetest.register_chatcommand("dump", { | |
params = "", | |
description = "Dump all objects in the global table", | |
func = function() | |
print("_G has "..#_G.." elements") | |
for k,v in pairs(_G) do | |
if k~="_G" then | |
if type(v)=="string" or type(v)=="number" then | |
print("G["..k.."]="..v) | |
elseif type(v)=="table" then | |
print("G["..k.."]=("..type(v)..")="..string.len(tostring(k)..tostring(v))) | |
else | |
print("G["..k.."]=("..type(v)..")") | |
end | |
end | |
end | |
return true, "Table dumped to console" | |
end | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment