Last active
December 30, 2015 01:59
-
-
Save cat-haines/7759246 to your computer and use it in GitHub Desktop.
Recursively traverses a Squirrel table (or object) and logs the results.
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 stringify(t, i = 0) { | |
local indentString = ""; | |
for(local x = 0; x < i; x++) indentString += "."; | |
if (typeof(t) != "table" && typeof(t) != "array") { | |
server.log(indentString + t) | |
} else { | |
foreach(k, v in t) { | |
if (typeof(v) == "table" || typeof(v) == "array") { | |
local par = "[]"; | |
if (typeof(v) == "table") par = "{}"; | |
server.log(indentString + k + ": " + par[0].tochar()); | |
stringify(v, i+4); | |
server.log(indentString + par[1].tochar()); | |
} | |
else { | |
server.log(indentString + k + ": " + v); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment