Module:ChartConstantDetail:修订间差异
DrLee lihr(讨论 | 贡献) (创建页面,内容为“local p = {} local chartConstantList = require("Module:LoadJson").ChartConstant() local songlist = require("Module:LoadJson").Songlist() local specialSongNameConverter = {} specialSongNameConverter["#1f1e33"]="#1f1e33" specialSongNameConverter["AI[UE]OON"]="AI[UE]OON" function p.main() local finText = [[{| class="wikitable sortable" style="text-align:center" |- ! style="position:-webkit-sticky;position:sticky;top:0px;" |曲目 ! style="color:#501…”) |
DrLee lihr(讨论 | 贡献) (笑死了 我把byd定数改没了居然没人发现.jpg) |
||
(未显示2个用户的9个中间版本) | |||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local chartConstantList = | local chartConstantList = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'ChartConstant.json' }) | ||
local songlist = | local songlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' }) | ||
local trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' }) | |||
local | local function constantFormat (a) | ||
if not(a) then | |||
return "<span class=\"old-constant\"> - </span>" | |||
end | |||
if a["old"] == true then | |||
return "<span class=\"old-constant\">" .. string.format("%.1f", a["constant"]) .. "</span>" | |||
else | |||
return string.format("%.1f", a["constant"]) | |||
end | |||
end | |||
function p.main() | function p.main() | ||
第15行: | 第22行: | ||
|- | |- | ||
! style="position:-webkit-sticky;position:sticky;top:0px;" |曲目 | ! style="position:-webkit-sticky;position:sticky;top:0px;" |曲目 | ||
! style="color:#1082be;position:-webkit-sticky;position:sticky;top:0px;" |PST | |||
! style="color:#648c3c;position:-webkit-sticky;position:sticky;top:0px;" |PRS | |||
! style="color:#50194b;position:-webkit-sticky;position:sticky;top:0px;" |FTR | ! style="color:#50194b;position:-webkit-sticky;position:sticky;top:0px;" |FTR | ||
! style="color:#ff0000;position:-webkit-sticky;position:sticky;top:0px;" |BYD | ! style="color:#ff0000;position:-webkit-sticky;position:sticky;top:0px;" |BYD | ||
]] | ]] | ||
第33行: | 第40行: | ||
end | end | ||
table.sort(constantList, function (a, b) return a[2][3]["constant"]>b[2][3]["constant"] end) | table.sort(constantList, function (a, b) | ||
if (not a[2][3]) or (not b[2][3]) then | |||
return a[3] > b[3] -- 暂时补洞,解决方案再讨论 | |||
end | |||
return a[2][3]["constant"]>b[2][3]["constant"] end) | |||
local link | |||
for i, k in pairs(constantList) do | |||
link = "[[" .. k[3] .. "]]" | |||
if | if trans["sameName"][k[3]] then | ||
link = "[[" .. trans["sameName"][k[3]][k[1]] .. "|" .. k[3] .. "]]" | |||
end | end | ||
if trans["songNameToDisplayName"][k[3]] then | |||
link = "[[" .. trans["songNameToDisplayName"][k[3]] .. "|" .. k[3] .. "]]" | |||
end | |||
finText = finText | |||
.. "|-\n|" .. link .. "||" | |||
.. constantFormat(k[2][1]) .. "||" | |||
.. constantFormat(k[2][2]) .. "||" | |||
.. constantFormat(k[2][3]) .. "||" | |||
.. constantFormat(k[2][1 | |||
.. constantFormat(k[2][2 | |||
.. constantFormat(k[2][3 | |||
if k[2][4] then | if k[2][4] then | ||
finText = finText .. constantFormat(k[2][4 | finText = finText .. constantFormat(k[2][4]) | ||
end | end | ||
finText = finText .. "\n" | finText = finText .. "\n" | ||
end | end | ||
2022年9月2日 (五) 23:47的最新版本
可在Module:ChartConstantDetail/doc创建此模块的帮助文档
local p = {}
local chartConstantList = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'ChartConstant.json' })
local songlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' })
local trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' })
local function constantFormat (a)
if not(a) then
return "<span class=\"old-constant\"> - </span>"
end
if a["old"] == true then
return "<span class=\"old-constant\">" .. string.format("%.1f", a["constant"]) .. "</span>"
else
return string.format("%.1f", a["constant"])
end
end
function p.main()
local finText =
[[{| class="wikitable sortable" style="text-align:center"
|-
! style="position:-webkit-sticky;position:sticky;top:0px;" |曲目
! style="color:#1082be;position:-webkit-sticky;position:sticky;top:0px;" |PST
! style="color:#648c3c;position:-webkit-sticky;position:sticky;top:0px;" |PRS
! style="color:#50194b;position:-webkit-sticky;position:sticky;top:0px;" |FTR
! style="color:#ff0000;position:-webkit-sticky;position:sticky;top:0px;" |BYD
]]
local constantList = {}
for i, k in pairs(chartConstantList) do
local realName = ""
for n, m in pairs(songlist["songs"]) do
if m["id"] == i then
realName = m["title_localized"]["en"]
break
end
end
table.insert(constantList, {i, k, realName})
end
table.sort(constantList, function (a, b)
if (not a[2][3]) or (not b[2][3]) then
return a[3] > b[3] -- 暂时补洞,解决方案再讨论
end
return a[2][3]["constant"]>b[2][3]["constant"] end)
local link
for i, k in pairs(constantList) do
link = "[[" .. k[3] .. "]]"
if trans["sameName"][k[3]] then
link = "[[" .. trans["sameName"][k[3]][k[1]] .. "|" .. k[3] .. "]]"
end
if trans["songNameToDisplayName"][k[3]] then
link = "[[" .. trans["songNameToDisplayName"][k[3]] .. "|" .. k[3] .. "]]"
end
finText = finText
.. "|-\n|" .. link .. "||"
.. constantFormat(k[2][1]) .. "||"
.. constantFormat(k[2][2]) .. "||"
.. constantFormat(k[2][3]) .. "||"
if k[2][4] then
finText = finText .. constantFormat(k[2][4])
end
finText = finText .. "\n"
end
finText = finText .. "|}"
return finText
end
return p