Module:ChartConstantSingle:修订间差异

来自Arcaea中文维基
(创建页面,内容为“local p = {} local chartConstantList = require("Module:LoadJson").ChartConstant() local songlist = require("Module:LoadJson").Songlist() function p.main(songName) local m = {} for i, k in pairs(songlist["songs"]) do if k["name"] == songName then m = chartConstantList[k["id"]] end end local function constantFormat (a) if not(a) then return "<span style=\"old-constant\"> - </span>" end…”)
 
无编辑摘要
第6行: 第6行:
    local m = {}
    local m = {}
    for i, k in pairs(songlist["songs"]) do
    for i, k in pairs(songlist["songs"]) do
      if k["name"] == songName then
      if k["title_localized"]["en"] == songName then
        m = chartConstantList[k["id"]]
        m = chartConstantList[k["id"]]
      end
      end
第20行: 第20行:
      end
      end
    end
    end
    local args = {
    local arguments = {
      constantFormat(m[1]),
      PST = constantFormat(m[1]),
      constantFormat(m[2]),
      PRS = constantFormat(m[2]),
      constantFormat(m[3]),
      FTR = constantFormat(m[3]),
    }
    }
    if m[4] then args[4] = constantFormat(m[4]) end
    if m[4] then arguments["BYD"] = constantFormat(m[4]) end
    return mw.getCurrentFrame():expandTemplate { title = '曲目定数', args = args }
    return mw.getCurrentFrame():expandTemplate { title = '曲目定数', args = arguments }
end
end




return p
return p

2022年7月10日 (日) 22:11的版本

可在Module:ChartConstantSingle/doc创建此模块的帮助文档

local p = {}
local chartConstantList = require("Module:LoadJson").ChartConstant()
local songlist = require("Module:LoadJson").Songlist()

function p.main(songName)
    local m = {}
    for i, k in pairs(songlist["songs"]) do
        if k["title_localized"]["en"] == songName then
            m = chartConstantList[k["id"]]
        end
    end
    local function constantFormat (a)
        if not(a) then
            return "<span style=\"old-constant\"> - </span>"
        end
        if a["old"] == true then
            return "<span style=\"old-constant\">" .. 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