Module:Sandbox/Aidan9382: Difference between revisions

Content deleted Content added
namecall test
dump function cause i wanna see inside table
Line 8:
function functions:namecall()
return self
end
 
local function Dump(t,depth,result,indent,recursion)
local depth = depth or 10
local result = result or ""
local indent = indent or 0
local recursion = recursion or {}
for a,b in next,t do
--Indent the table
result = result .. string.rep(" ",indent)
--Represent the key (we dont expand table keys)
if type(a) == "string" then
result = result .. "\""..a.."\": "
else
result = result .. ""..tostring(a)..": "
end
--Represent the value
if type(b) == "string" then
result = result .. "\""..b.."\""
elseif type(b) == "table" then
if depth == 0 then
result = result .. tostring(b) .. "[ Depth limit ]"
elseif recursion[b] then
result = result .. tostring(b) .. "[ Recursion ]"
else
recursion[b] = true
result = result .. Dump(b,depth-1,result,indent+2,recursion)
end
else
result = result .. tostring(b)
end
--Finalise line
result = result .. "\n"
end
return result
end
function functions:RawInfo()
return "<syntaxhighlight lang=text>\n"..Dump(self,5).."\n</syntaxhighlight>"
end