local function totablestring(x) return type(x) == "string" and string.format("\"%s\"", x) or tostring(x) end local function tprint(tbl, c, indent, done) c, indent, done = c or 0, indent or 0, done or {} if type(tbl) == "table" then local output, sameType = {}, true for key, value in pairs(tbl) do if type(key) ~= "number" then sameType = false end end for key, value in pairs(tbl) do table.insert(output, string.rep(" ", indent)) if type(value) == "table" and not done[value] then done[value] = true if c == 1 and sameType then table.insert(output, key .. " = {\n" .. string.rep(" ", indent+2) .. table.concat(value, ", ") .. "\n}\n") elseif c == 2 and sameType then table.insert(output, key .. " = { " .. table.concat(value, ", ") .. " }\n") else table.insert(output, key .. " = {\n" .. tprint(value, c, indent + 2, done) .. string.rep(" ", indent) .. "}\n") end elseif type(key) == "number" then table.insert(output, totablestring(value)) else table.insert(output, key .. " = " .. totablestring(value) .. "\n") end end return table.concat(output) else return tostring(tbl) .. "\n" end end local function pprint(x, compactinglvl) compactinglvl = compactinglvl or 2 if type(x) == "nil" then print(tostring(nil)) elseif type(x) == "table" then print(tprint(x, compactinglvl)) elseif type(x) == "string" then print(x) else print(tostring(x)) end end