36 lines
733 B
Lua
36 lines
733 B
Lua
local self = {}
|
|
|
|
function self.toString(tbl,checkedTbls,depth)
|
|
if depth == nil then depth = 0 end
|
|
if checkedTbls == nil then checkedTbls = {} end
|
|
table.insert(checkedTbls,tbl)
|
|
local str = ""
|
|
local i = depth
|
|
local prefix = ">"
|
|
while i > 0 do
|
|
prefix = prefix .. ">"
|
|
i = i - 1
|
|
end
|
|
prefix = prefix .. " "
|
|
for i,v in pairs(tbl) do
|
|
if type(v) == "table" then
|
|
local found = false
|
|
for i2,v2 in pairs(checkedTbls) do
|
|
if v2 == v then
|
|
found = true
|
|
break
|
|
end
|
|
end
|
|
|
|
if found == false then
|
|
str = str .. prefix.. tostring(i) .. ":\n" ..self.toString(v,checkedTbls,depth + 1)
|
|
end
|
|
else
|
|
str = str .. prefix.. tostring(i) .. ": " ..tostring(v).. "\n"
|
|
end
|
|
end
|
|
|
|
return str
|
|
end
|
|
|
|
return self |