Last active
February 27, 2018 19:05
-
-
Save Dreezn/2fa66703c5d42e22ce7ce2e78aa7bf87 to your computer and use it in GitHub Desktop.
PrintHMembers for Pico8
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
function printhmembers(o, indent) | |
if type(o) == "table" then | |
if indent==nil then | |
printh("{") | |
printhmembers(o,0) | |
printh("}") | |
else | |
local padding="" | |
for i=0,indent do | |
padding=padding.." " | |
end | |
local itemnb=0 | |
for key,value in pairs(o) do | |
itemnb+=1 | |
if (type(value)=="table") then | |
printh(padding..key..":{") | |
printhmembers(value, indent+1) | |
printh(padding.."}") | |
else | |
local output=tostr(value) | |
if (type(value)=="string") output="\""..output.."\"" | |
printh(padding..key..":"..tostr(value)) | |
end | |
end | |
end | |
else | |
printh("printhmembers error: not a table") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment