Module:Adjacent stations: Difference between revisions

Content deleted Content added
m arbitrary parameter numbering
m slightly more efficient?
Line 88:
local t = {}
for ik, =v 1,in ipairs(args.nums[#args.nums] or 1) do
if args.system[iv] then
header =table.insert(t, table.concat({'\n|-',
'\n!', style['header leftcell'], 'Preceding station',
'\n!', style['header midcell'], data[iv]['system title'],
'\n!', style['header rightcell'], 'Following station'})
}))
table.insert(t, header)
end
if args.line[iv] then
local _line = data[iv][args.line[iv]]
lineTitle[iv] = _line['line title']
colour[iv] = _line.colour
note[iv] = args.note[iv] or ''
if type(_line['left terminus']) == 'string' then
_leftTerminus = _line['left terminus']
elseif type(_line['left terminus']) == 'table' then
_leftTerminus = _line['left terminus'][args.TypeL[iv] or 1]
end
if type(_line['right terminus']) == 'string' then
_rightTerminus = _line['right terminus']
elseif type(_line['right terminus']) == 'table' then
_rightTerminus = _line['right terminus'][args.TypeR[iv] or 1]
end
if not args.left[iv] then
left[iv] = "''Terminus''"
leftTerminus[iv] = ''
elseif args.left[iv] == _leftTerminus then
left[iv] = _line['station link'](args.left[iv])
leftTerminus[iv] = subFormat('Terminus')
else
left[iv] = _line['station link'](args.left[iv])
if args.onewayL[iv] == true then
leftTerminus[iv] = subFormat('One-way operation')
else
leftTerminus[iv] = subFormat('towards ' .. _line['station link'](_leftTerminus))
end
end
if not args.right[iv] then
right[iv] = "''Terminus''"
rightTerminus[iv] = ''
elseif args.right[iv] == _rightTerminus then
right[iv] = _line['station link'](args.right[iv])
rightTerminus[iv] = subFormat('Terminus')
else
right[iv] = _line['station link'](args.right[iv])
if args.onewayR[iv] == true then
rightTerminus[iv] = subFormat('One-way operation')
else
rightTerminus[iv] = subFormat('towards ' .. _line['station link'](_rightTerminus))
end
end
table.insert(t, table.concat({'\n|-',
'\n|', style['body leftcell'], left[iv], leftTerminus[iv],
'\n|', style['body banner'], colour[iv], '"| ',
'\n|', style['body midcell'], lineTitle[iv], '<div style="font-size: smaller">', note[iv], '</div>' ,
'\n|', style['body banner'], colour[iv], '"|&nbsp;',
'\n|', style['body rightcell'], right[iv] , rightTerminus[iv]
}))
end
Line 177:
}
local _args = frame:getParent().args
local tmp = {}
for k, v in pairs(_args) do
local a = string.match(k, '(%a+)%d+')
Line 189 ⟶ 190:
if a == 'system' then
args.system[b] = v
tmp[b] = true
table.insert(args.nums, b)
elseif a == 'line' then
args.line[b] = v
tmp[b] = true
table.insert(args.nums, b)
elseif a == 'left' then
args.left[b] = v
-- tmp[b] = true
elseif a == 'right' then
args.right[b] = v
-- tmp[b] = true
elseif a == 'typeL' then
args.TypeL[b] = v
Line 220 ⟶ 223:
end
for k, v in pairs(tmp) do table.insert(args.nums, bk) end
table.sort(args.nums)
local data = {}
for ik, =v 1,in ipairs(args.nums[#args.nums] or 1) do
if args.system[iv] then
data[iv] = require('Module:L-rail/' .. args.system[iv])
else
data[iv] = data[iargs.nums[k-1]]
end
end