本WIKI由秋漫语申请于2021年10月28日创建 本条目中所使用的数据、图片和歌词,其著作权属于原著作权人,仅以介绍为目的引用!
本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~

全站通知:

模块:CharaQuote

来自Muse DashWIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:CharaQuote/doc创建

-- 原模块链接:wiki.biligame.com/klbq/Module:CharaQuote

local getArgs = require("Module:Arguments").getArgs
local p = {}

function p.main(frame)
    local args = getArgs(frame, {
        removeBlanks = false
    })
    local noJP = false
    local buffer = {}
    local tableClass = ""
    local cntdstyle = 'style="background-color: rgba(230,230,230,.3)"'
    local jptdstyle = 'style="background-color: rgba(235,248,255,.5)"'

    -- 遍历检查noJP等参数
    for k, _ in pairs(args) do
        if (k == "noJP") then
            noJP = true
            tableClass = " nojp"
        end
    end

    table.insert(buffer, '{| class="voice-table' .. tableClass .. '"')
    local i = 0
    -- 遍历其他数字参数,生成表格
    for key, value in ipairs(args) do
        i = i + 1
        local Audiotd = (value == "" and "" or frame:expandTemplate {title = "Audio", args = {value}})
        
        if noJP then
            -- 当提供noJP参数时,每三个参数形成一组行和单元格
            if (i % 3 == 1) then
                table.insert(buffer, "|-")
                table.insert(buffer, "| rowspan=1 |" .. value)
            elseif (i % 3 == 2) then
                table.insert(buffer, "| " .. cntdstyle .. "|" .. Audiotd)
            elseif (i % 3 == 0) then
                table.insert(buffer, "| " .. cntdstyle .. "|" .. value)
            end
        else
            -- 默认情况,每五个参数形成一组行和单元格
            if (i % 5 == 1) then
                table.insert(buffer, "|-")
                table.insert(buffer, "| rowspan=2 |" .. value)
            elseif (i % 5 == 2) then
                table.insert(buffer, "| " .. cntdstyle .. "|" .. Audiotd)
            elseif (i % 5 == 3) then
                table.insert(buffer, "| " .. cntdstyle .. "|" .. value)
            elseif (i % 5 == 4) then
                table.insert(buffer, "|-")
                table.insert(buffer, "| " .. jptdstyle .. "|" .. Audiotd)
            elseif (i % 5 == 0) then
            	table.insert(buffer, "| " .. jptdstyle .. "|" .. (value == "" and "" or '<span lang="ja">' .. value .. "</span>"))
            end
        end
    end
    table.insert(buffer, "|}")
    return table.concat(buffer, "\n")
end

return p