缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:表格/工艺品
刷
历
编
< 模块:表格
跳到导航
跳到搜索
此模块的文档可以在模块:表格/工艺品/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 po = require([[Module:Po]]).po
local utils = require([[Module:Utils]])
local afData = mw.loadData([[Module:Data/Artifacts]])
local TYPE_ARTIFACT = {
[0] = "太空工艺品",
[1] = "陆地工艺品",
[2] = "一般工艺品"
};
local TYPE_LightShape = {
[0] = "点状光源",
[1] = "锥形光源",
[2] = "平行光源"
};
local function rgba_to_hex(r, g, b, a)
-- 转换为0到255之间的整数
r = math.floor(r * 255)
g = math.floor(g * 255)
b = math.floor(b * 255)
a = math.floor(a * 255)
-- 返回16进制颜色字符串
return string.format("#%02X%02X%02X%02X", r, g, b, a)
end
local function getCometName(itemData)
if itemData.Name ~= nil then
local name = po(itemData.Name)
if not utils.isDefaultT(itemData.Name, name) then
return fstr("{{物品|%s}}", name)
end
end
return fstr("<code>%s</code>", itemData.Id)
end
-- test by: = p._main({})
function p._main(itemData)
local out_name = ""
local out_desc = ""
local out_desc2 = ""
local out_decor = ""
local out_decorRadius = ""
local out_rarity = ""
local out_category = ""
local out_chance = ""
local out_dlcs = ""
-- 名称
if itemData.Name ~= nil then
-- 名称
local name = po(itemData.Name)
if not utils.isDefaultT(itemData.Name, name) then
out_name = fstr('<div style="text-align:center;">{{图|84|%s}}<br>%s</div>', name, name)
else
out_name = fstr("<code>%s</code>", itemData.id)
end
-- 描述
local descCode = itemData.Name:sub(1, -6) .. ".DESCRIPTION"
out_desc = po(descCode)
if utils.isDefaultT(descCode, out_desc) then
out_desc = ""
end
-- 分析描述
local analsyCode = itemData.Name:sub(1, -6) .. ".ARTIFACT"
out_desc2 = po(analsyCode)
if utils.isDefaultT(analsyCode, out_desc2) then
out_desc2 = ""
end
else
table.insert(out, "")
end
if itemData.decorProvider ~= nil then
-- 装饰度
out_decor = utils.float2str(itemData.decorProvider.baseDecor)
-- 影响半径
out_decorRadius = utils.float2str(itemData.decorProvider.baseRadius)
end
local spaceArtifact = itemData.spaceArtifact
if spaceArtifact ~= nil then
local artifactTier = spaceArtifact.artifactTier
-- 稀有度
out_rarity = po(artifactTier.name_key.String)
-- 分类
local type = TYPE_ARTIFACT[spaceArtifact.artifactType]
out_category = type ~= nil and type or ""
-- 分析时获得振荡仪充能器的概率
out_chance = fstr("%s%%", utils.float2str(artifactTier.payloadDropChance * 100))
end
if itemData.Name ~= nil then
end
-- DLC图标
if itemData.dlcIds ~= nil and itemData.entityType == "ArtifactConfig" then
out_dlcs = table.concat(utils.map(itemData.dlcIds, function(dlc)
return fstr("%s", utils.DLC_ICONS[dlc])
end), "<br/>")
end
return {out_name, out_decor, out_decorRadius, out_rarity, out_category, out_desc, out_desc2, out_chance, out_dlcs}
end
function p._lightTable(itemData)
local out = {}
-- 名称
if itemData.Name ~= nil then
-- 名称
local name = po(itemData.Name)
if not utils.isDefaultT(itemData.Name, name) then
table.insert(out, fstr('<div style="text-align:center;">{{图|84|%s}}<br>%s</div>', name, name))
else
table.insert(out, fstr("<code>%s</code>", itemData.id))
end
else
table.insert(out, "")
end
local light2D = itemData.light2D
-- 距离
table.insert(out, utils.float2str(light2D.Range))
-- 亮度
table.insert(out, utils.float2str(light2D.Lux))
-- 光线类型
local shapeName = TYPE_LightShape[light2D.shape]
table.insert(out, shapeName ~= nil and shapeName or "")
-- 颜色
local color = light2D.Color
local colorHex = rgba_to_hex(color.r, color.g, color.b, color.a)
table.insert(out, fstr('<div style="width: 8px; height: 8px; background-color: %s;"></div> %s', colorHex, colorHex))
-- DLC图标
if itemData.dlcIds ~= nil then
table.insert(out, table.concat(utils.map(itemData.dlcIds, function(dlc)
return fstr("%s", utils.DLC_ICONS[dlc])
end), "<br/>"))
else
table.insert(out, "")
end
return out
end
-- test by: = p.main(require("Module:debug").frame({},{debug=1}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, entityType="ArtifactConfig"}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, entityType="KeepsakeConfig"}))
function p.main(frame)
local args = getArgs(frame)
local infos = {}
local entityType = args.entityType
for artId, artData in pairs(afData) do
if entityType == nil or (artData.entityType ~= nil and artData.entityType == entityType) then
local info = p._main(artData)
table.insert(infos, info)
end
end
if args.debug then
mw.logObject(infos, "infos")
end
return tb.table(infos, args)
end
-- test by: = p.lightTable(require("Module:debug").frame({},{debug=1}))
-- test by: = p.lightTable(require("Module:debug").frame({},{debug=1, entityType="ArtifactConfig"}))
function p.lightTable(frame)
local args = getArgs(frame)
local infos = {}
local entityType = args.entityType
for artId, artData in pairs(afData) do
if entityType == nil or (artData.entityType ~= nil and artData.entityType == entityType) then
if artData.light2D ~= nil then
local info = p._lightTable(artData)
table.insert(infos, info)
end
end
end
if args.debug then
mw.logObject(infos, "infos")
end
return tb.table(infos, args)
end
return p