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

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

全站通知:

模块:表格/蓝图

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

此模块的文档可以在模块:表格/蓝图/doc创建

local p = {}
local fstr = mw.ustring.format
local getArgs = require('Module:Dev/Arguments').getArgs
local outfits = mw.loadData("Module:Data/Blueprints/Outfits")
local clothing = mw.loadData("Module:Data/Blueprints/Clothing")
local po = require([[Module:po]]).po

local dupeDefault = {
    DupeTops = "默认上衣",
    DupeBottoms = "默认下身",
    DupeGloves = "默认手套",
    DupeShoes = "默认鞋子"
}

local atmoDefault = {
    AtmoSuitHelmet = "默认气压服头盔",
    AtmoSuitBody = "默认气压服制服",
    AtmoSuitGloves = "默认气压服手套",
    AtmoSuitBelt = "默认气压服腰带",
    AtmoSuitShoes = "默认气压服靴子"
}

local function GetNamesFromOutfit(outfitname, items, cat)
	local names = {}
    for _, v in ipairs(items) do
        local item = clothing[v]
        names[item["category"]] = po("STRINGS." .. item["name"])
    end
    local sortedNames = {po(outfitname)}
    if cat == "Clothing" then
        for _, v in pairs{
            "DupeTops",
            "DupeBottoms",
            "DupeGloves",
            "DupeShoes"
        } do
            sortedNames[#sortedNames + 1] = fstr("{{物品|%s}}", names[v] or dupeDefault[v])
        end
    elseif cat == "AtmoSuit" then
        for _, v in pairs{
            "AtmoSuitHelmet",
            "AtmoSuitBody",
            "AtmoSuitGloves",
            "AtmoSuitBelt",
            "AtmoSuitShoes"
        } do
            sortedNames[#sortedNames + 1] = fstr("{{物品|%s}}", names[v] or atmoDefault[v])
        end
    end
    return sortedNames
end

--	test by: p._main({"Clothing"})
--	test by: p._main({"AtmoSuit"})
function p._main(args)
	if not args then return end
	local rows = {}
	for _, outfit in ipairs(outfits) do
		if outfit["type"] == args[1] then
			rows[#rows+1] = GetNamesFromOutfit(outfit["name"], 
				outfit["items"], outfit["type"])
		end
	end
	-- mw.logObject(rows)
	return require([[Module:表格]]).table(rows)
end

-- test by: p.main()
function p.main(frame)
    return p._main(getArgs(frame))
end

return p