缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!

该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!

全站通知:

模块:信息框/遗迹

来自缺氧WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:信息框/遗迹/doc创建

local infobox = require([[Module:信息框]])
local fstr = mw.ustring.format
local p = {}

local innerNodes = {
    {
        tag = 'image',
        source = '图片',
        children = {
            {
                tag = 'caption',
                source = '图片说明'
            }
        }
    },
    {
        tag = 'data',
        source = 'ID',
        label = 'ID'
    },
    {
        tag = 'data',
        source = '尺寸',
        label = '[[File:图标_尺寸.png|16px|link=|class=dark-invert]] 尺寸'
    },
    {
        tag = 'data',
        source = '装饰',
        label = '[[File:图标_装饰.png|16px|link=]] 装饰'
    },
    {
        tag = "group",
        header = "库存",
        attr = {collapse = 'open'},
        children = {
            {
                tag = 'data',
                source = '机械臂运送',
                label = '机械臂运送'
            },
            {
                tag = 'data',
                source = '允许清空库存',
                label = '允许清空库存'
            },
            {
                tag = 'data',
                source = '库存容量',
                label = '库存容量'
            },
            {
                tag = 'data',
                source = '存储物品',
                label = '存储物品'
            }
        }
    },
    {
        tag = 'group',
        header = '构成',
        attr = {collapse = 'open'},
        children = {
            {
                tag = 'data',
                source = '元素',
                label = '主要元素'
            },
            {
                tag = 'data',
                source = '质量',
                label = '质量'
            },
            {
                tag = 'data',
                source = '初始温度',
                label = '初始温度'
            }
        }
    },
    {
        tag = 'group',
        header = '可用DLC',
        attr = {collapse = 'open'},
        children = {
            {
                tag = 'data',
                source = '可用DLC'
            }
        }
    }
}

-- test: = p.infoboxContent{['分类'] = "[[人造材料]]", ['ID'] = "Algae"}
function p.infoboxContent(args)
    args['尺寸'] = "宽 " .. tostring(args['宽度']) .. " 高 " .. tostring(args['高度'])
    if args['装饰值'] ~= nil and args['装饰半径'] ~= nil then
        args['装饰'] = fstr("%s(范围:%s 格)", tostring(args['装饰值']), tostring(args['装饰半径']))
    end
    local generated = {}
    for _, n in ipairs(innerNodes) do
        local child = infobox.genNode(n, args)
        if child ~= nil then
            table.insert(generated, child)
        end
    end
    return generated
end

function p.main(title, data, raw)
    local contentNodes = nil
    if #data == 1 then
        contentNodes = p.infoboxContent(data[1].data)
    else
        local panelData = {}
        for _, pData in ipairs(data) do
            table.insert(panelData, {
                label = pData.label,
                content = p.infoboxContent(pData.data)
            })
        end
        contentNodes = {
            infobox.panel(panelData)
        }
    end
    return infobox.infobox(title, contentNodes, raw, 'element')
end

function p.demo(frame)
    local getArgs = require('Module:Dev/Arguments').getArgs
    local args = getArgs(frame)
    return p.main(args['标题'], {
        {
            data = args
        }
    }, args.raw)
end

return p