Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
init.lua - dump lua global table with table element size estimate
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