Jump to content

Module:Sandbox/Ahecht/sandbox: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
update
update
Line 6: Line 6:


function p.main(frame)
function p.main(frame)
local mwSite, mwSiteStats = '', ''
local mwSite = ''
for k,v in pairs(mw.site) do if type(v) == 'string' then mwSite = mwSite .. '\n*' .. k .. ': ' .. v end end
for k,v in pairs(mw.site) do
mwSite = mwSite .. '\n*mw.site.' .. k .. ': '
for k,v in pairs(mw.site.stats) do if type(v) ~= 'function' then mwSiteStats = mwSiteStats .. '\n**' .. k .. ': ' .. v end end
if type(v) == 'string' or type(v) == 'number' then
return 'mw.site: ' .. mwSite .. '\n*mw.site.stats: ' .. mwSiteStats
mwSite = mwSite .. v
elseif type(v) == 'table' then
for kk,vv in pairs(v) do
if type(vv) == 'table' then vv = '[table]' end
if type(vv) ~= 'function' then
mwSite = mwSite .. '\n**mw.site.' .. k .. '.' .. kk .. ': ' .. vv
end
end
end
end
return mwSite
end
end



Revision as of 17:09, 21 March 2018

local p = {}

local function _main(args)
	return true
end

function p.main(frame)
	local mwSite = ''
	for k,v in pairs(mw.site) do
		mwSite = mwSite .. '\n*mw.site.' .. k .. ': '
		if type(v) == 'string' or type(v) == 'number' then
			mwSite = mwSite .. v
		elseif type(v) == 'table' then
			for kk,vv in pairs(v) do
				if type(vv) == 'table' then vv = '[table]' end
				if type(vv) ~= 'function' then
					mwSite = mwSite .. '\n**mw.site.' .. k .. '.' .. kk .. ': ' .. vv
				end
			end
		end
	end
	return mwSite
end

return p