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

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

全站通知:

模块:世界生成导航

来自缺氧WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索
-- Module:世界生成导航
local p = {}
local fstr = mw.ustring.format -- shortcut for formattig a string
local utils = require([[Module:Utils]])
local po = require([[Module:Po]]).po
local getArgs = require('Module:Dev/Arguments').getArgs
local navbox = require([[Module:导航栏]])
local worldsDataBASE = mw.loadData([[Module:Data/Worldgen/Worlds]])
local worldsDataDLC1 = mw.loadData([[Module:Data/Worldgen/Worlds/Expansion1]])
local clustersBASE = mw.loadData([[Module:Data/Worldgen/Clusters]])
local clustersDLC1 = mw.loadData([[Module:Data/Worldgen/Clusters/Expansion1]])

function p.dlc1()
    local out = {"<span>[[眼冒金星!]]世界生成</span>"}

    local orderedClusters = {}
    local usedWorlds = {}
    for _, cData in pairs(clustersDLC1) do
        if cData.skip == nil then
            for _, world in ipairs(cData.worldPlacements) do
                local worldsData =
                    utils.startswith(world.world, "expansion1::") and
                        worldsDataDLC1 or worldsDataBASE
                local worldId = mw.ustring.match(world.world, "worlds/(.+)$")
                local worldNameCode = worldsData[worldId .. ".yaml"].name
                usedWorlds[worldNameCode] = true
            end
            table.insert(orderedClusters, cData)
        end
    end
    table.sort(orderedClusters,
               function(a, b) return a.menuOrder < b.menuOrder end)

    local catedclusters = {[1] = {}, [2] = {}, [3] = {}}
    for _, cData in ipairs(orderedClusters) do
    	if cData.clusterCategory == 1 or cData.clusterCategory == "SpacedOutVanillaStyle" then
        	table.insert(catedclusters[1], cData)
    	elseif cData.clusterCategory == 2 or cData.clusterCategory == "SpacedOutStyle" then
        	table.insert(catedclusters[2], cData)
    	else
        	table.insert(catedclusters[3], cData)
    	end
    end

    table.insert(out, "经典风格[[星群]]")
    table.insert(out, table.concat(utils.map(catedclusters[1], function(cData)
        local name = po(cData.name)
        return fstr("{{物品|%s}}", name)
    end), " ! "))

    table.insert(out, "眼冒金星风格")
    table.insert(out, table.concat(utils.map(catedclusters[2], function(cData)
        local name = po(cData.name)
        return fstr("{{物品|%s}}", name)
    end), " ! "))
    
    table.insert(out, "其它")
    table.insert(out, table.concat(utils.map(catedclusters[3], function(cData)
        local name = po(cData.name)
        return fstr("{{物品|%s}}", name)
    end), " ! "))

    table.insert(out, "星群[[小行星]]")
    local worlds = {}
    for worldFile, wData in pairs(worldsDataDLC1) do
        local worldNameCode = worldsDataDLC1[worldFile].name
        if usedWorlds[worldNameCode] then
            table.insert(worlds, wData)
            usedWorlds[worldNameCode] = nil
        end
    end
    table.insert(out, table.concat(utils.map(worlds, function(wData)
        local name = po(wData.name)
        return fstr("{{物品|%s}}", name)
    end), " ! "))

    out.collapse = "no"

    -- mw.logObject(out)
    return navbox.main(out)
end

function p.base()
    local out = {"本体游戏世界生成"}
    local orderedClusters = {}
    for _, cData in pairs(clustersBASE) do
        if cData.skip == nil then table.insert(orderedClusters, cData) end
    end
    table.sort(orderedClusters,
               function(a, b) return a.menuOrder < b.menuOrder end)

    table.insert(out, "[[小行星类型]]")
    table.insert(out, table.concat(utils.map(orderedClusters, function(cData)
        local name = po(cData.name)
        return fstr("{{物品|%s}}", name)
    end), " ! "))

    out.collapse = "no"

    -- mw.logObject(out)
    return navbox.main(out)
end

-- test by: = p.main()
function p.main(frame) return tostring(p.dlc1()) .. tostring(p.base()) end

return p