Hello OTLand. Since I know by experience that sometimes it's hard to understand what's inside tables that you didn't write, that most of the times are returned by functions.
A good way to see exactly how a table looks like is to make it as a string.
Here is the script the will convert any table to a string:
This one can be useful for you LUA scripters out there. The function is tested and will give you a perfect result.
Try it out yourself.
Note: It still doesn't support threads yet.
A good way to see exactly how a table looks like is to make it as a string.
Here is the script the will convert any table to a string:
Lua:
function tableString(tb, showInt)
local tb_string = ""
local function table_calculate(tb, sub, key)
if type(tb) == "table" then
tb_string = tb_string .. ((type(key) == "string") and (key .. " = ") or ((type(key) == "number" and showInt) and "[".. key .."] = " or "")) .. "{"
for k, v in pairs(tb) do
if type(v) == "table" then
table_calculate(v, (next(tb, k) and true or false), k)
else
if type(v) == "string" then
v = "\"" .. v .. "\""
elseif type(v) == "boolean" then
v = (v and "true" or "false")
elseif type(v) == "nil" then
v = "nil"
elseif type(v) == "function" then
v = "function" .. "()"
end
tb_string = tb_string .. (type(k) == "string" and (k .. " = ") or (showInt and "[".. k .."] = " or "")) .. v .. (next(tb, k) and ", " or "")
end
end
tb_string = tb_string .. "}" .. (sub and ", " or "")
else
return false
end
return true
end
-- Write maintable.
if table_calculate(tb, false) then
return tb_string
else
return false
end
end
Try it out yourself.
Note: It still doesn't support threads yet.
Last edited: