Created
October 21, 2017 20:17
-
-
Save jthistle/ac283f3ab7fe494297e022133a042e32 to your computer and use it in GitHub Desktop.
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
function tableAsString(tbl) | |
toReturn = "{" | |
for ind, val in pairs(tbl) do | |
if type(val) == "table" then | |
toReturn = toReturn .. (type(ind) == "number" and "" or ind .. "=") .. tableAsString(val) .. "," | |
else | |
local newVal | |
if type(val) == "string" then | |
newVal = "\"" .. val .. "\"" | |
else | |
newVal = val | |
end | |
toReturn = toReturn .. (type(ind) == "number" and "" or ind .. "=") .. newVal .. "," | |
end | |
end | |
toReturn = toReturn:sub(1,-2) .. "}" -- remove trailing "," and close table | |
return toReturn | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment