Module:ChartConstantDetail:修订间差异
(创建页面,内容为“local p = {} local songlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' }) local songlistAppend = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist append.json' }) local trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' }) local getArgs = require('Module:Arguments').getArgs function getInfList() -- 返回一个数据表。 local songlistE = {} loc…”) |
无编辑摘要 |
||
第24行: | 第24行: | ||
songInf["title_localized"]["default"] , | songInf["title_localized"]["default"] , | ||
ratingClass, | ratingClass, | ||
diffInf["ratingReal"] | diffInf["ratingReal"], | ||
songInf["artist"], | |||
diffInf["chartDesigner"] | |||
}) | }) | ||
end | end | ||
第46行: | 第48行: | ||
songInf["title_localized"]["default"] , | songInf["title_localized"]["default"] , | ||
ratingClass, | ratingClass, | ||
diffInf["ratingReal"] | diffInf["ratingReal"], | ||
songInf["artist"], | |||
diffInf["chartDesigner"] | |||
}) | }) | ||
end | end | ||
第64行: | 第68行: | ||
local inf = getInfList() | local inf = getInfList() | ||
table.sort(inf, function(a, b) return a[4] > b[4] end) | |||
local outputTable = mw.html.create("table"):addClass("rotable") | |||
local outputTable = mw.html.create("table") | |||
outputTable:tag("tr"):tag("th"):wikitext("曲绘"):tag("th"):wikitext("曲目") | outputTable:tag("tr"):tag("th"):wikitext("曲绘"):tag("th"):wikitext("曲目") | ||
:tag("th"):wikitext("曲师"):tag("th"):wikitext("谱师") | :tag("th"):wikitext("曲师"):tag("th"):wikitext("谱师") | ||
:tag("th"):wikitext("难度"):tag("th"):wikitext("定数") | :tag("th"):wikitext("难度"):tag("th"):wikitext("定数") | ||
for _,inf in ipairs(inf) | |||
do | |||
outputTable:tag("tr"):tag("th"):wikitext("[[File:Songs "..inf[1]..".png|75px]]") | |||
:tag("th"):wikitext(inf[2]) | |||
:tag("th"):wikitext(inf[5]):tag("th"):wikitext(inf[6]) | |||
:tag("th"):wikitext(inf[3]):tag("th"):wikitext(inf[4]) | |||
end | |||
2022年8月27日 (六) 18:22的版本
可在Module:ChartConstantDetail/doc创建此模块的帮助文档
local p = {} local songlist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' }) local songlistAppend = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist append.json' }) local trans = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Template:Transition.json' }) local getArgs = require('Module:Arguments').getArgs function getInfList() -- 返回一个数据表。 local songlistE = {} local appendList = {} -- 记录在songlistAppend中存在的曲目,避免重复列举 local ratingClass for _,songInf in ipairs(songlistAppend["songs"]) do for _,diffInf in ipairs(songInf["difficulties"]) do if diffInf["ratingClass"] == 0 then ratingClass = "I" elseif diffInf["ratingClass"] == 1 then ratingClass = "II" elseif diffInf["ratingClass"] == 2 then ratingClass = "III" elseif diffInf["ratingClass"] == 3 then ratingClass = "IV" end table.insert(songlistE,{ songInf["id"], songInf["title_localized"]["default"] , ratingClass, diffInf["ratingReal"], songInf["artist"], diffInf["chartDesigner"] }) end appendList[songInf["id"]] = true end for _,songInf in ipairs(songlist["songs"]) do if songInf["difficulties"] and not(appendList[songInf["id"]]) then for _,diffInf in ipairs(songInf["difficulties"]) do if diffInf["ratingClass"] == 0 then ratingClass = "I" elseif diffInf["ratingClass"] == 1 then ratingClass = "II" elseif diffInf["ratingClass"] == 2 then ratingClass = "III" elseif diffInf["ratingClass"] == 3 then ratingClass = "IV" end table.insert(songlistE,{ songInf["id"], songInf["title_localized"]["default"] , ratingClass, diffInf["ratingReal"], songInf["artist"], diffInf["chartDesigner"] }) end end end return songlistE end function p.main(frame) local args = getArgs(frame) return p._main(args) end function p._main(args) local inf = getInfList() table.sort(inf, function(a, b) return a[4] > b[4] end) local outputTable = mw.html.create("table"):addClass("rotable") outputTable:tag("tr"):tag("th"):wikitext("曲绘"):tag("th"):wikitext("曲目") :tag("th"):wikitext("曲师"):tag("th"):wikitext("谱师") :tag("th"):wikitext("难度"):tag("th"):wikitext("定数") for _,inf in ipairs(inf) do outputTable:tag("tr"):tag("th"):wikitext("[[File:Songs "..inf[1]..".png|75px]]") :tag("th"):wikitext(inf[2]) :tag("th"):wikitext(inf[5]):tag("th"):wikitext(inf[6]) :tag("th"):wikitext(inf[3]):tag("th"):wikitext(inf[4]) end return outputTable end return p