无编辑摘要 标签:已被回退 |
无编辑摘要 标签:已被回退 |
||
| 第1行: | 第1行: | ||
-- Module:BusDepot | -- Module:BusDepot | ||
local p = {} | local p = {} | ||
function p.count(frame) | |||
local depot = frame.args.depot or '' | |||
local depot_counts = mw.loadData('Module:BusDepot/Data') or {} | |||
local current_depot = depot_counts.current_depot or '' | |||
local depot1 = tonumber(depot_counts.depot1 or 1) | |||
local num = tonumber(depot_counts.num or 0) | |||
if current_depot == '' then | |||
depot1 = 1 | |||
num = 0 | |||
elseif current_depot == depot then | |||
depot1 = depot1 + 1 | |||
else | |||
num = num + 1 | |||
depot1 = 1 | |||
end | |||
-- 保存状态(模拟持久化) | |||
depot_counts.current_depot = depot | |||
depot_counts.depot1 = depot1 | |||
depot_counts.num = num | |||
depot_counts[depot] = depot1 | |||
return '' | |||
end | |||
function p.display(frame) | function p.display(frame) | ||
local html = mw.html.create('table'):addClass('wikitable') | local html = mw.html.create('table'):addClass('wikitable') | ||
html:node(frame:expandTemplate{ title = '线路配车表格头' }) | html:node(frame:expandTemplate{ title = '线路配车表格头' }) | ||
return tostring(html) | return tostring(html) | ||
end | end | ||
return p | return p | ||
2025年4月15日 (二) 11:03的版本
此模块的文档可以在模块:BusDepot/doc创建
-- Module:BusDepot
local p = {}
function p.count(frame)
local depot = frame.args.depot or ''
local depot_counts = mw.loadData('Module:BusDepot/Data') or {}
local current_depot = depot_counts.current_depot or ''
local depot1 = tonumber(depot_counts.depot1 or 1)
local num = tonumber(depot_counts.num or 0)
if current_depot == '' then
depot1 = 1
num = 0
elseif current_depot == depot then
depot1 = depot1 + 1
else
num = num + 1
depot1 = 1
end
-- 保存状态(模拟持久化)
depot_counts.current_depot = depot
depot_counts.depot1 = depot1
depot_counts.num = num
depot_counts[depot] = depot1
return ''
end
function p.display(frame)
local html = mw.html.create('table'):addClass('wikitable')
html:node(frame:expandTemplate{ title = '线路配车表格头' })
return tostring(html)
end
return p