Модуль:Debug
Модуль:Debug (обг. · · історія · посилання · документація · підсторінки · тести – результати)
local m = {}
local function table_print(tt, indent)
indent = indent or 0
if type(tt) == "table" then
local sb = {}
for key, value in pairs (tt) do
table.insert(sb, string.rep (" ", indent))
if type(value) == "table" then
table.insert(sb, tostring(key).." =\n");
table.insert(sb, table_print (value, indent + 2))
elseif type(value) == "number" then
table.insert(sb, string.format("%s = %s\n", tostring (key), tostring(value)))
else
table.insert(sb, string.format(
"%s = \"%s\"\n", tostring (key), tostring(value)))
end
end
return table.concat(sb)
else
return tt .. "\n"
end
end
function m.print(tbl)
if type(tbl) == 'nil' then
return tostring(nil)
elseif type(tbl) == 'table' then
return table_print(tbl)
elseif type(tbl) == 'string' then
return tbl
else
return tostring(tbl)
end
end
return m
Увага! Опитування читачів ВУЕ.
Заповнити анкету ⟶