Module:WhatDoWeHave
Documentation for this module may be created at Module:WhatDoWeHave/doc
local p = {}
function p.pptable(table, max, depth)
local depth = depth or 1
local s = ""
for k,v in pairs(table) do
local t = type(v)
s = s .. string.rep('*', depth) .. "'''" .. k .. "''': " .. t
if t == "string" or t == "number" or t == "boolean" then
s = s .. " (\"'''" .. string.gsub(v, "\n", " ") .. "'''\")\n"
elseif t == "function" or t == "nil" or t == "userdata" then
s = s .. "\n"
elseif t == "table" then
if depth < max and v ~= _G then
s = s .. ":\n" .. p.pptable(v, max, depth+1)
else
s = s .. "\n"
end
end
end
return s
end
function p.show(frame)
local table = frame.args[1] or "_G"
local maxdepth = tonumber(frame.args[2]) or 3
return p.pptable(_G[table], maxdepth)
end
function p.showframe(frame)
return p.pptable(frame, 3)
end
return p