缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:图库/小行星
刷
历
编
< 模块:图库
跳到导航
跳到搜索
此模块的文档可以在模块:图库/小行星/doc创建
-- Module:图库/星群
local p = {}
local fstr = mw.ustring.format -- shortcut for formattig a string
local gallerybox = require([[Module:图库]])
local utils = require([[Module:Utils]])
local po = require([[Module:Po]]).po
local yesno = require([[Module:Dev/Yesno]])
local getArgs = require('Module:Dev/Arguments').getArgs
local clustersBASE = mw.loadData([[Module:Data/Worldgen/Clusters]])
local clustersDLC1 = mw.loadData([[Module:Data/Worldgen/Clusters/Expansion1]])
local clustersDLC2 = mw.loadData([[Module:Data/Worldgen/Clusters/Dlc2]])
local worldsDataBASE = mw.loadData([[Module:Data/Worldgen/Worlds]])
local worldsDataDLC1 = mw.loadData([[Module:Data/Worldgen/Worlds/Expansion1]])
local worldsDataDLC2 = mw.loadData([[Module:Data/Worldgen/Worlds/Dlc2]])
local asteroids = {}
local usedAsteroids = {}
local function contains(t, e)
if t == nil then
return false
end
for _, i in ipairs(t) do
if i == e then
return true
end
end
return false
end
function p.isDLC1(cData)
if cData.forbiddenDlcIds ~= nil then
for _, dlc in ipairs(cData.forbiddenDlcIds) do
if dlc == "EXPANSION1_ID" then
return false
end
end
end
if cData.requiredDlcIds ~= nil then
for _, dlc in ipairs(cData.requiredDlcIds) do
if dlc == "EXPANSION1_ID" then
return true
end
end
end
return false
end
function p.setWorld(cData, dlc)
if cData.worldPlacements == nil then
return
end
for _, world in ipairs(cData.worldPlacements) do
local worldsData = nil
if utils.startswith(world.world, "expansion1::") then
worldsData = worldsDataDLC1
elseif utils.startswith(world.world, "dlc2::") then
worldsData = worldsDataDLC2
else
worldsData = worldsDataBASE
end
if worldsData ~= nil then
local worldId = mw.ustring.match(world.world, "worlds/(.+)$")
local wData = worldsData[worldId .. ".yaml"]
local nameCode = wData.name
if usedAsteroids[nameCode] == nil then
usedAsteroids[nameCode] = true
table.insert(asteroids, {
name = nameCode,
desc = wData.description,
menuOrder = cData.menuOrder
})
end
end
end
end
-- test by: = p.main(require("Module:debug").frame({},{debug=1}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, base=true}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, base=false}))
function p.main(frame)
local sections = {}
local args = getArgs(frame)
local csList = {clustersBASE, clustersDLC1, clustersDLC2}
for _, cs in ipairs(csList) do
for _, cData in pairs(cs) do
if cData.skip == nil then
if p.isDLC1(cData) == not yesno(args.base) then
p.setWorld(cData)
end
end
end
end
table.sort(asteroids, function(a, b)
return a.menuOrder < b.menuOrder
end)
local gallerys = utils.map(asteroids, function(cData)
local name = po(cData.name)
local desc = po(cData.desc)
return {
name = name,
desc = fstr("[[%s]]是%s", name, desc)
}
end)
local out = gallerybox.gallery(gallerys)
if args.debug then
mw.logObject(out, "out")
end
return mw.getCurrentFrame():preprocess(out)
end
return p

沪公网安备 31011002002714 号