Module:Sandbox/Sameboat/m1: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(160 intermediate revisions by the same user not shown)
Line 1:
local getArgs = require('Module:Arguments').getArgs
local p = {}
local p = {}
function p.id( frame )
 
local pframe = frame:getParent()
function p.navbar(frame)
local config = frame.args
local argsnavbar = pframerequire('Module:Navbar').argsnavbar
return navbar('asd')
local system = frame.args[1]
local code = frame.args[2]
if not system or not code then
return 'error'
end
local data = require('Module:HK-MTR_stations/' .. system)
local station = data.stations[code]
return code .. '' .. station.id
end
 
p.lengthcheck = function()
function p.link( frame )
local pframeasd = frame:getParent()'123456789'
return string.len(asd)
local config = frame.args
end
local args = pframe.args
 
local system = frame.args[1]
p.indextable = function()
local code = frame.args[2]
local result = ''
if not system or not code then
local t={}
return 'error'
t[#t+1]='odin'.. 1 + 0
end
t[#t+1]='dva'.. '1 + 1'
local data = require('Module:HK-MTR_stations/' .. system)
t[#t+1]='tri'.. 1.5 * 2
local station = data.stations[code]
return codetable.concat(t, ', ') .. station'.link'
end
local function makeInvokeFunction(funcName)
-- makes a function that can be returned from #invoke, using
-- [[Module:Arguments]].
return function (frame)
local args = getArgs(frame, {parentOnly = true})
return p[funcName](args)
end
end
p.link = makeInvokeFunction('_link')
function p._link(args)
local result='{|class="wikitable"\n|-'
local t = {
{h='a', d='1a'},
{h='b', d='2b'},
{h='c', d='3c'},
{h='d', d='4d'},
}
t[5] = {h = 'e', d = '5e'}
t[6] = {h = 'f', d = '6f'}
t[7] = {h = 'g', d = '7g'}
for i,v in ipairs(t) do
if i==5 then break
else
result=result..'\n!'..v.h
end
end
result=result..'\n|-'
for i,v in ipairs(t) do
result=result..'\n|'..v.d
end
result=result..'\n|-'
local t = {
{h='aa', d='1aa'},
{h='bb', d='2bb'},
{h='cc', d='3cc'},
{h='dd', d='4dd'},
}
for i,v in ipairs(t) do
result=result..'\n!'..v.h
end
result=result..'\n|-'
for i,v in ipairs(t) do
result=result..'\n|'..v.d
end
return result .. '\n|}'
end
p.row = makeInvokeFunction('_row')
function p._row(args)
local somelist = args[1]
local result
result = ''
for k1, v1 in ipairs(mw.text.split(somelist, '\n')) do
for k2, v2 in ipairs(mw.text.split(v1 .. '\\', '\\')) do
if k2 > 2 then break
elseif (k2 % 2 == 1) then
if (k1 % 2 == 0) then
result = result .. '\n|-style="background:#888"\n!' .. k1 .. '\n|' .. v2
else result = result .. '\n|-\n!' .. k1 .. '\n|' .. v2
end
elseif (k2 % 2 == 0) then result = result .. '||' .. v2
end
end
end
result = '{|class="wikitable"' .. result .. '\n|}'
return result
end