Module:Sandbox/Aidan9382

This is an old revision of this page, as edited by Aidan9382 (talk | contribs) at 09:03, 27 September 2022 (dump function cause i wanna see inside table). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require("Module:No globals")
local functions = {}

function functions.main(data)
	return "<div style=text-align:right;font-size:80%>This does nothing as of right now. "..os.time().."</div>"
end

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

return functions