舰R百科是靠无数志愿编辑者持续地建设更新完善的。编辑非常简单,无需代码知识,请勇于更新页面!
编辑入门 | 资助百科 | 留言讨论页 | 微博@舰R百科 | 百科编辑讨论Q群:366818861

模块:家具图鉴:修订间差异

舰R百科,玩家自由编辑的战舰少女R百科
跳转到导航 跳转到搜索
Donnyjie留言 | 贡献
无编辑摘要
Donnyjie留言 | 贡献
无编辑摘要
第7行: 第7行:


local function expand(idx)
local function expand(idx)
    local furn = furns[tostring(idx)]
     local args = { idx }
     local args = { idx }
     return curFrame:expandTemplate{ title = '家具', args = args }
     return curFrame:expandTemplate{ title = '家具', args = args }

2017年4月27日 (四) 19:40的版本

{{#invoke:家具图鉴|按星级|5}}
{{#invoke:家具图鉴|按套装|5}}

脚本错误:函数“按套装”不存在。


local data = mw.loadData("模块:数据库/家具")
local furns = data.furns

local p = { }

local curFrame = nil

local function expand(idx)
    local args = { idx }
    return curFrame:expandTemplate{ title = '家具', args = args }
end

p['按星级'] = function(frame)
    curFrame = frame
    local star = frame.args[1]
    local cnt = 0
    local ret = '{| class="wikitable" style="width:100%; text-align:center; "'
    for i,v in ipairs(furns) do
        if v.star == star then
            if cnt < 2 then
                ret = ret .. '\n| style="width:50%" |' .. expand(v.id)
            else
                ret = ret .. '\n|' .. expand(i)
            end
            cnt = cnt + 1
            if cnt % 2 == 0 then
                ret = ret .. '\n|-'
            end
        end
    end
    if cnt % 2 ~= 0 then
        for i = cnt % 2 + 1, 2 do
            ret = ret .. '\n|'
        end
    end
    return ret .. '\n|}'
end

return p