打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

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

SegFault留言 | 贡献2016年10月23日 (日) 02:47的版本 (创建页面,内容为“local data = mw.loadData("模块:特殊数据") local ships = data.ships local byIndex = data.byIndex local p = { } local curFrame = nil local function expand(idx...”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
{{#invoke:图鉴|按编号|1|10}}

模块:特殊数据第3行Lua错误:attempt to index local 'data' (a boolean value)

{{#invoke:图鉴|按类型|BB|1|10}}

模块:特殊数据第3行Lua错误:attempt to index local 'data' (a boolean value)


local data = mw.loadData("模块:特殊数据")
local ships = data.ships
local byIndex = data.byIndex

local p = { }

local curFrame = nil

local function expand(idx)
    local name = byIndex[idx]
    local link = byIndex[idx % 1000]
    local ship = ships[name]
    local moe = ship['萌王']
    if moe == nil then moe = '' end
    local args = { idx, name:gsub('·改', ''), link, ship.rarity, ship.type:lower(), moe }
    return curFrame:expandTemplate{ title = '图鉴立绘2', args = args }
end

local function genShipList(idx)
    local part1 = ''
    local part2 = ''
    local empty1 = true
    local empty2 = true
    local prefix = '\n|width="200px"|'
    for i = idx + 1, idx + 5 do
        part1 = part1 .. prefix
        if byIndex[i] ~= nil then
            part1 = part1 .. expand(i)
            empty1 = false
        end
    end
    if not empty1 then prefix = '\n|' end
    for i = idx + 6, idx + 10 do
        part2 = part2 .. prefix
        if byIndex[i] ~= nil then
            part2 = part2 .. expand(i)
            empty2 = false
        end
    end
    if empty1 and empty2 then
        return nil
    elseif empty1 then
        return '{|\n|- valign="bottom"' .. part2 .. '\n|}\n'
    elseif empty2 then
        return '{|\n|- valign="bottom"' .. part1 .. '\n|}\n'
    else
        return '{|\n|- valign="bottom"' .. part1 .. '\n|-' .. part2 .. '\n|}\n'
    end
end

p['按编号'] = function(frame)
    curFrame = frame
    local l = math.floor((tonumber(frame.args[1]) - 1) / 10) * 10
    local r = math.floor((tonumber(frame.args[2]) - 1) / 10) * 10
    local ret = ''
    local buf = ''
    for i = l, r, 10 do
        local title = '===No.' .. (i + 1) .. '~' .. (i + 10) .. '===\n'
        local list = genShipList(i)
        if list ~= nil then
            ret = ret .. buf .. title .. list
            buf = ''
        else
            buf = buf .. title
        end
    end
    return ret
end

return p