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

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

全站通知:

模块:间歇泉导航

来自缺氧WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索
-- Module:间歇泉导航
local p = {}
local fstr = mw.ustring.format
local getArgs = require([[Module:Arguments]]).getArgs
local navbox = require([[Module:导航栏]])
local utils = require([[Module:Utils]])
local po = require([[Module:Po]]).po
local gDatas = mw.loadData([[Module:Data/Geysers]])
local DLC_ICONS = utils.DLC_ICONS
local geyserShapes = { -- GeyserConfigurator.GeyserShape
    "气体", -- Gas
    "一般液体", -- Liquid
    "岩浆/熔融金属" -- Molten
}

function p._main()
    local out = {"<span>间歇泉</span>"}
    out.collapse = "no"

    local geysers = {}
    
    for key, gData in pairs(gDatas) do
        local gType = gData.geyserType
        if gType ~= nil then
            local shape = gType.shape + 1
            geysers[shape] = geysers[shape] or {}
            local dlc = gType.DlcID
            local gCode = "STRINGS.CREATURES.SPECIES.GEYSER." .. gType.id:upper() .. ".NAME"
            local name = po(gCode)
            if not utils.isDefaultT(gCode, name) then
                table.insert(geysers[shape], {
                    name = name,
                    dlc = dlc,
                })
            end
        end
    end

    for i, shape in pairs(geyserShapes) do
        local gDatas = geysers[i]
        if gDatas ~= nil then
            table.sort(gDatas, function(a, b)
                return a.dlc < b.dlc
            end)
            table.insert(out, shape)
            table.insert(out, table.concat(utils.map(gDatas, function(data)
                return fstr("{{物品|%s}}", data.name) .. (data.dlc > "" and DLC_ICONS[data.dlc] or "")
            end), " ! "))
        end
    end

    return out
end

-- test by: = p.main(require("Module:debug").frame({},{debug=1}))
function p.main(frame)
    local args = getArgs(frame)
    local out = p._main()
    if args.debug then
        mw.logObject(out)
    end
    return navbox.main(out)
end

return p