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

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

全站通知:

模块:表格/固体

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

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

-- Module:表格/固体
local p = {}
local fstr = mw.ustring.format -- shortcut for formattig a string
local getArgs = require('Module:Dev/Arguments').getArgs
local tb = require([[Module:表格]])
local eModule = require([[Module:元素信息框]])
local po = require([[Module:Po]]).po
local utils = require([[Module:Utils]])
local elData = mw.loadData([[Module:Data/Elements]])

-- test by: = p._main({})
function p._main(args)
    local out = {}
    local ids = {}
    for _, ele in pairs(elData) do
        if ele.state == "Solid" then
            if not utils.isDefaultT(ele.localizationID, po(ele.localizationID)) then
                table.insert(ids, ele.elementId)
            end
        end
    end
    table.sort(ids, function(a, b) -- put disabled elements at back
        if elData[a].isDisabled ~= elData[b].isDisabled then
            return elData[b].isDisabled
        end
        return a < b
    end)
	-- those are pages that can not be mapped correctly
	local pageMatch = {
		StableSnow = "紧压雪",
	}
    for _, id in ipairs(ids) do
        local ele = elData[id]
        local name = fstr("{{物品|%s}}", pageMatch[ele.elementId] or po(ele.localizationID))
        if ele.isDisabled then name = name .. "<wbr>(禁用)" end
        if ele.dlcId == "EXPANSION1_ID" then
            name = name .. " <wbr>{{眼冒金星图标}}"
        end

        local shc = utils.float2str(ele.specificHeatCapacity, 3)

        local tc = ele.thermalConductivity

        local highTemp = utils.float2str(ele.highTemp + utils.K0)

        local highTempTarget = ""
        if ele.highTempTransitionOreId then
            local page1 = eModule.id2pageName(ele.highTempTransitionTarget)
            local page2 = eModule.id2pageName(ele.highTempTransitionOreId)
            local ratio2 = tonumber(ele.highTempTransitionOreMassConversion)
            local ratio1 = 1 - ratio2
            highTempTarget = fstr("[[%s]]:[[%s]] = <wbr>%.2f : %.2f", page1, page2,
                                  ratio1, ratio2)
        elseif ele.highTempTransitionTarget ~= nil then
            local page1 = eModule.id2pageName(ele.highTempTransitionTarget)
            highTempTarget = fstr("[[%s]]", page1)
        end

        local hardness = ele.hardness or ""

        local molarMass = ele.molarMass or ""

        local cat = ""
        if ele.materialCategory then
            local catName = po(eModule.tagCode(ele.materialCategory))
            cat = fstr("[[:category:%s|%s]]", catName, catName)
        end

        local tags = {}
        for _, t in ipairs(ele.tags or {}) do
            local tName = po(eModule.tagCode(t))
            if utils.isDefaultT(eModule.tagCode(t), tName) then
                tName = t
            end
            table.insert(tags, fstr("[[:category:%s|%s]]", tName, tName))
        end
        tags = table.concat(tags, "、<wbr>")

        local defaultTemperature = ele.defaultTemperature + utils.K0

        local defaultMass = ele.defaultMass or ""

        local maxMass = ele.maxMass or ""

        local strength = ele.strength or ""
        
        local radiationAbsorptionFactor = fstr('%.2f', tonumber(ele.radiationAbsorptionFactor) or 0)

        table.insert(out, {
            name, shc, tc, highTemp, highTempTarget, hardness, molarMass, cat,
            tags, defaultTemperature, defaultMass, maxMass, strength, radiationAbsorptionFactor
        })

    end
    return tb.table(out, args)
end

function p.main(frame) return p._main(getArgs(frame)) end

return p