Module:ChartConstantSingle:修订间差异
DrLee lihr(讨论 | 贡献) 无编辑摘要 |
DrLee lihr(讨论 | 贡献) (fix) |
||
第18行: | 第18行: | ||
end | end | ||
if | if m == {} then | ||
for i, k in pairs(songlist["songs"]) do | for i, k in pairs(songlist["songs"]) do | ||
if k["title_localized"]["en"] == songName then | if k["title_localized"]["en"] == songName then |
2022年7月21日 (四) 22:37的版本
可在Module:ChartConstantSingle/doc创建此模块的帮助文档
local p = {}
local chartConstantList = require("Module:LoadJson").ChartConstant()
local songlist = require("Module:LoadJson").Songlist()
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame)
local songName = args[1]
local m = {}
-- 这里这个逻辑是优先进行id匹配,以区分两个 Quon —— DrLee_lihr
for i, k in pairs(songlist["songs"]) do
if k["id"] == songName then
m = chartConstantList[k["id"]]
break
end
end
if m == {} then
for i, k in pairs(songlist["songs"]) do
if k["title_localized"]["en"] == songName then
m = chartConstantList[k["id"]]
break
end
end
end
local function constantFormat (a)
if not(a) then
return "<span style=\"font-weight:lighter; color:silver; font-style:italic;\"> - </span>"
end
if a["old"] == true then
return "<span style=\"font-weight:lighter; color:silver; font-style:italic;\">" .. string.format("%.1f", a["constant"]) .. "</span>"
else
return string.format("%.1f", a["constant"])
end
end
local arguments = {
PST = constantFormat(m[1]),
PRS = constantFormat(m[2]),
FTR = constantFormat(m[3]),
}
if m[4] then arguments["BYD"] = constantFormat(m[4]) end
return mw.getCurrentFrame():expandTemplate { title = '曲目定数', args = arguments }
end
return p