缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:表格/影响页面
刷
历
编
< 模块:表格
跳到导航
跳到搜索
此模块的文档可以在模块:表格/影响页面/doc创建
-- 表格/影响页面
local p = {}
local utils = require([[Module:Utils]])
local vData = require([[Module:Data/版本]])
local moduleVersion = require([[Module:游戏版本]])
local tb = require([[Module:表格]])
local getArgs = require('Module:Dev/Arguments').getArgs
local fstr = mw.ustring.format -- shortcut for formattig a string
local sepEntry = "<br>"
local sepSec = "@$"
local paramInclude = {}
for _, v in ipairs({"1", "build", "ex"}) do
table.insert(paramInclude, fstr("{游戏版本}:%s", v))
end
paramInclude = table.concat(paramInclude, ",")
function p._main(args)
local match = args.pagename:match("-.+")
local match = match and match:sub(2)
local build = tonumber(match)
local version = build and vData[build]
if version == nil then
return tb.error(fstr(
"找不到页面“%s”对应的版本,请联系管理员。",
args.pagename), args)
end
local dplArgs = {
"title=复制人",
"title=资源",
format = "," .. sepEntry .. "%TITLE%|",
include = paramInclude,
count = 999999,
secseparators = sepSec
}
if type(version.affected_pages) ~= "table" or (#version.affected_pages == 0) then
return tb.error(args.textNoAffected or "没有受影响的页面", args)
end
for _, pName in ipairs(version.affected_pages) do
table.insert(dplArgs, fstr("title=%s", pName))
end
local dplResult = mw.getCurrentFrame():callParserFunction('#dpl:', dplArgs)
local affected = {}
local lines = mw.text.split(dplResult, sepEntry, true)
for i = 2, #lines do
local secs = mw.text.split(lines[i], "|", true)
local currTitle = secs[1]
local rawArgs = mw.text.split(secs[2], sepSec, true)
local versionArgs = {}
versionArgs[1] = rawArgs[2] ~= "" and rawArgs[2] or nil
versionArgs.build = rawArgs[3] ~= "" and rawArgs[3] or nil
versionArgs.ex = rawArgs[4] ~= "" and rawArgs[4] or nil
local currBuild = moduleVersion.getBuild(versionArgs)
affected[currTitle] = {build = currBuild}
end
local out = {}
local cat = args[1]
for _, pName in ipairs(version.affected_pages) do
local currVersion = args.textNoPage or "页面不存在"
if affected[pName] ~= nil then
local affectedPageBuild = affected[pName].build
if vData[affectedPageBuild] == nil then
currVersion = fstr("%s(未识别版本)" , affectedPageBuild)
else
currVersion = fstr("[[%s|%s]]", vData[affectedPageBuild].page,
affectedPageBuild)
end
end
table.insert(out, {
fstr("[[%s]]", pName), -- name
currVersion -- current version
})
end
return tb.table(out, args)
end
-- test by: =p._main{pagename="U35-477316", textNoAffected="没有受影响的页面"}
-- test by: =p._main{pagename="版本/U34-475139", textNoAffected="没有受影响的页面"}
-- test by: =p._main{pagename="Template:版本页脚"}
function p.main(frame) return p._main(getArgs(frame)) end
return p