Jump to content

Module:Sandbox/Ahecht and Module:Sandbox/Ahecht/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
dots
 
simplify
 
Line 1: Line 1:
local p = {}
local p = {}


local dots = ...
local function _main(args)
return true
end


function p.main(frame)
function p.main(frame)
local output = {}
local mwSite = ''
for k,v in pairs(mw.site) do
output[1] = 'frame: ' .. type(frame) .. ' '
mwSite = mwSite .. '\n*mw.site.' .. k .. ': '
if frame[1] then
if type(v) == 'string' or type(v) == 'number' then
output[2] = frame[1]
mwSite = mwSite .. v
else
output[2] = ''
elseif type(v) == 'table' then
for kk,vv in pairs(v) do if type(vv) == 'string' or type(vv) == 'number' then mwSite = mwSite .. '\n**mw.site.' .. k .. '.' .. kk .. ': ' .. vv end end
end
output[3] = '<br />frame.args: ' .. type(frame.args) .. ' '
if frame.args[1] then
output[4] = frame.args[1]
else
output[4] = ''
end
output[5] = '<br />frame:getParent().args ' .. type(frame:getParent().args) .. ' '
if frame:getParent().args[1] then
output[6] = frame:getParent().args[1]
else
output[6] = ''
end
if frame.args['test'] == 0 then
output[7] = '<br />0 the number'
elseif frame.args['test'] == '0' then
output[7] = '<br />0 the character'
else
output[7] = ''
end
local thisframe = mw.getCurrentFrame()
if thisframe then
output[8] = "<br />mw.getCurrentFrame():getTitle(): "
output[9] = thisframe:getTitle()
thisframe = thisframe:getParent()
if thisframe then
output[10] = "<br />mw.getCurrentFrame():getParent():getTitle(): "
output[11] = thisframe:getTitle()
thisframe = thisframe:getParent()
if thisframe then
output[12] = "<br />mw.getCurrentFrame():getParent():getParent():getTitle(): "
output[13] = thisframe:getTitle()
end
end
end
end
end
return table.concat(output)
return mwSite
end

function p.isnumeric(frame)
local s = frame.args[1] or frame:getParent().args[1]
local boolean = (frame.args.boolean or frame:getParent().args.boolean) == 'true'
if type(s) == 'string' and mw.getContentLanguage():parseFormattedNumber( s ) then
return boolean and 1 or s
end
return boolean and 0 or ''
end

function error(t, key)
t[key] = function () return "Error! Missing function " .. key end
return t[key]
end

metatable = {['__index'] = error}

setmetatable(p, metatable)

function p.dots()
return dots
end
end