Created
January 9, 2019 14:08
-
-
Save Srlion/41427627926054dd05066b625f1113d1 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
local COLOR_KEY = Color(0, 255, 0) | |
local COLOR_VALUE = Color(255, 255, 0) | |
local COLOR_DEFAULT = Color(255, 255, 255) | |
local COLOR_DOTS = Color(0, 0, 255) | |
do | |
local MsgC = MsgC | |
local istable = istable | |
local isstring = isstring | |
local tostring = tostring | |
local tabs | |
function PrintType(tbl) | |
if (!istable(tbl)) then | |
MsgC(COLOR_VALUE, tostring(tbl), "\n") | |
return | |
end | |
local first | |
if (!tabs) then | |
tabs = 0 | |
first = true | |
end | |
local tabStr = ("| "):rep(tabs) | |
for k, v in pairs(tbl) do | |
local comma = next(tbl, k) != nil && "," || "" | |
if (isstring(k)) then | |
k = "\"" .. k .. "\"" | |
else | |
k = tostring(k) | |
end | |
MsgC(COLOR_DOTS, tabStr, COLOR_DEFAULT, "[", COLOR_KEY, k, COLOR_DEFAULT, "] = ") | |
local _type = type(v) | |
if (istable(v)) then | |
if next(v) == nil then | |
MsgC(COLOR_DEFAULT, "{}") | |
else | |
MsgC(COLOR_DEFAULT, "{\n") | |
tabs = tabs + 1 | |
PrintType(v) | |
tabs = tabs - 1 | |
MsgC(COLOR_DOTS, tabStr, COLOR_DEFAULT, "}") | |
end | |
else | |
if (isstring(v)) then | |
v = "\"" .. v .. "\"" | |
else | |
v = tostring(v) | |
end | |
MsgC(COLOR_VALUE, v) | |
end | |
MsgC(COLOR_DEFAULT, comma) | |
Msg("\n") | |
end | |
if (first) then | |
tabs = nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment