Module:BPMTable

From Rhythm Heaven Wiki
Revision as of 11:02, 8 July 2025 by TheAlternateDoctor (talk | contribs) (Fixing it?)
Jump to navigation Jump to search

Module accepts 3 arguments:

  • title: Name of the second column. Most likely to be "Beat", or "Game".
  • Unnamed argument 1: List of tempos, separated by a comma. Ex: "120,125"
  • Unnamed argument 2: List of labels. Displayed to the right of the corresponding tempo. Ex: "Tengoku,Megamix" or "0,16"

For instance:

{{#invoke:BPMTable|main|title=Beat|120,125|0,16}}

would resolve into:

BPMs
Beat
120 0
125 16
{{#invoke:BPMTable|main|title=Game|180,175|Tengoku,Megamix}}

would resolve into:

BPMs
Game
180 Tengoku
175 Megamix

local p = {}

function p.main(frame)
    local title = frame.args["title"]
    local items = frame.args[1]
    if items ~= nil then
        items = mw.text.split(items, ",")
    else
        items = {}
    end
    local labels = frame.args[2]
    if labels ~= nil then
        labels = mw.text.split(labels, ",")
    else
        labels = {}
    end
    local result = {}
    table.insert(result, '{|class="mw-collapsible mw-collapsed" style="color:white;width:25%;clear:both;background:black;border-radius: 10px;"')
    table.insert(result, '|-')
    table.insert(result, '! align="center" style="color:white;background:#4A31FF;border-radius:7px;" width="50%"|<div style="margin-left:75px;"><font color="White">BPMs</font></div>')
    table.insert(result, '! align="center" style="color:white;background:#4A31FF;border-radius:7px;"|'.. title)
    local i = 1
    while items[i] do
        table.insert(result, "|-")
        table.insert(result, "|"..items[i])
        if labels[i] ~= nil then
            table.insert(result, "|"..labels[i])
        end
        i = i + 1
    end
    table.insert(result, "|}")
    return table.concat(result, "\n")
end

return p