缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:流星信息框
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:流星信息框/doc创建
-- Module:流星信息框
local p = {}
local getArgs = require("Module:Dev/Arguments").getArgs
local fstr = mw.ustring.format
local po = require([[Module:Po]]).po
local i18nc = require([[Module:I18n]]).loadMessages([[Module:I18n/Ui]])
local utils = require("Module:Utils")
local k0 = utils.K0
local infobox = require([[Module:信息框/流星]])
local msData = mw.loadData([[Module:Data/MeteorShowers]])
local cData = mw.loadData([[Module:Data/Comets]])
local exception = {}
local function isMatchMeteorId(fData, id)
if fData.id:upper() == id:upper() then
return true
elseif fData.clusterMapMeteorShowerID ~= nil then
if ("ClusterMapMeteorShower_" .. id):upper() == fData.clusterMapMeteorShowerID:upper() then
return true
end
elseif fData.id:upper() == ("MeteorShower" .. id .. "Event"):upper() then
return true
elseif fData.id:upper() == ("Cluster" .. id .. "Shower"):upper() then
return true
end
return false
end
function p._main(itemData, itemCode)
local out = {}
local pageCats = {}
out["ID"] = fstr("<code>%s</code>", itemData.Id)
out["名称"] = po(itemData.Name)
out["图片"] = fstr("%s.png", out["名称"])
-- out["图片说明"] = po(itemCode:sub(1, -6) .. ".DESCRIPTION")
if itemData.primaryElement ~= nil then
local name, _ = utils.getEntry(itemData.primaryElement.Name)
out['主要成分'] = fstr("{{物品|%s}}", name)
end
local comet = itemData.comet
if comet ~= nil then
if comet.affectedByDifficulty ~= nil then
out['受难度影响'] = comet.affectedByDifficulty == true and "✔" or "✖"
end
-- 质量
if comet.massRange ~= nil then
out['质量范围'] = fstr("%s ↔ %s 千克", utils.float2str(comet.massRange.x),
utils.float2str(comet.massRange.y))
end
-- 温度
if comet.temperatureRange ~= nil then
out['温度范围'] = fstr("%s ↔ %s °C", utils.float2str(comet.temperatureRange.x + k0),
utils.float2str(comet.temperatureRange.y + k0))
end
-- 释放元素
if comet.exhaustElement ~= nil and comet.exhaustElement ~= "Void" then
local code = "STRINGS.ELEMENTS." .. comet.exhaustElement:upper() .. ".NAME"
local name = po(code)
if not utils.isDefaultT(code, name) then
out['尾焰元素'] = fstr("{{物品|%s}}", name)
end
-- 释放速率
if comet.EXHAUST_RATE ~= nil then
out['尾焰释放速率'] = fstr("%s 千克/秒", utils.float2str(comet.EXHAUST_RATE))
end
end
-- 爆炸速度
out['爆炸速度'] = fstr("%s ↔ %s 格/秒", utils.float2str(comet.explosionSpeedRange.x),
utils.float2str(comet.explosionSpeedRange.y))
-- 爆炸温度
out['爆炸温度'] = fstr("%s ↔ %s °C", utils.float2str(comet.explosionTemperatureRange.x + k0),
utils.float2str(comet.explosionTemperatureRange.y + k0))
-- 溅射范围
out['溅射范围'] = fstr("%s 格", utils.float2str(comet.splashRadius))
-- 爆炸后销毁
out['爆炸后销毁'] = comet.destroyOnExplode == true and "是" or "否"
-- 流速
out['流速'] = fstr("%s ↔ %s 秒/格", utils.float2str(comet.spawnVelocity.x),
utils.float2str(comet.spawnVelocity.y))
-- 掉落角度
out['掉落角度'] = fstr("%s° ↔ %s°", utils.float2str(comet.spawnAngle.x),
utils.float2str(comet.spawnAngle.y))
-- 被击落后的掉落物
if comet.lootOnDestroyedByMissile ~= nil then
local lootSet = {}
for _, loot in ipairs(comet.lootOnDestroyedByMissile) do
local lootOld = lootSet[loot]
if lootOld ~= nil then
lootSet[loot] = lootOld + 1
else
lootSet[loot] = 1
end
end
local loots = {}
for entityId, num in pairs(lootSet) do
local name = utils.getEntry(entityId)
if name ~= nil then
table.insert(loots, fstr("{{物品|%s}} x%s", name, utils.float2str(num)))
end
end
out['击落战利品'] = #loots > 0 and table.concat(loots, "<br/>") or nil
end
-- 抵达后创生物
if comet.craterPrefabs ~= nil then
local craterSet = {}
for _, crater in ipairs(comet.craterPrefabs) do
local lootOld = craterSet[crater]
if lootOld ~= nil then
craterSet[crater] = lootOld + 1
else
craterSet[crater] = 1
end
end
local craters = {}
for entityId, num in pairs(craterSet) do
local name = utils.getEntry(entityId)
if name ~= nil then
table.insert(craters, fstr("{{物品|%s}} x%s", name, utils.float2str(num)))
end
end
out['陨石坑生成物'] = #craters > 0 and table.concat(craters, "<br/>") or nil
end
-- 结块数量
if comet.addTiles ~= nil and comet.addTiles > 0 then
out['结块数量'] = utils.float2str(comet.addTiles)
-- 结块高度
out['结块高度'] = fstr("%s ↔ %s 格", utils.float2str(comet.addTilesMinHeight),
utils.float2str(comet.addTilesMaxHeight))
-- 结块细菌数量
if comet.diseaseId ~= nil and comet.addDiseaseCount ~= nil and comet.addDiseaseCount > 0 then
out['结块病菌'] = fstr("[[%s]] %s",
po("STRINGS.DUPLICANTS.DISEASES." .. comet.diseaseId:upper() .. ".NAME"),
utils.float2str(comet.addDiseaseCount))
end
end
out['使复制人受伤'] = comet.canHitDuplicants == true and "是" or nil
if comet.entityDamage ~= nil and comet.entityDamage > 0 then
out['实体伤害'] = utils.float2str(comet.entityDamage)
out['实体砖伤害加成'] = fstr("x%s", utils.float2str(comet.totalTileDamage))
end
end
table.insert(pageCats, "[[Category:流星]]")
return out, pageCats
end
-- test by: = p.main(require("Module:debug").frame({},{debug=1, "DustComet"}))
-- test by: = p.main(require("Module:debug").frame({},{debug=1, pagename="岩石流星"}))
function p.main(frame)
local args = getArgs(frame)
local comets = {}
if args ~= nil and args[1] ~= nil then
for _, meteorId in ipairs(args) do
for k, v in pairs(cData) do
if k:upper() == meteorId:upper() then
table.insert(comets, {
id = k,
code = v.Name,
data = v
})
end
end
end
else
local cometCode = i18nc:msgRev({
key = args.pagename,
args = {
prefix = "STRINGS.UI.SPACEDESTINATIONS.COMETS."
}
} or "")
if cometCode == nil then
error(fstr("找不到流星 '%s',请使用参数1或检查 [[%s]]。", args.pagename,
"[[Module:Data/Comets]]"))
else
for k, v in pairs(cData) do
if v.Name == cometCode then
table.insert(comets, {
id = k,
code = v.Name,
data = v
})
break
end
end
end
end
if #comets <= 0 then
error(
fstr("找不到流星 '%s',请使用参数1或检查 [[%s]]。", args.pagename, "[[Module:Data/Comets]]"))
end
-- 找到所有流量雨id
local infos = {}
local pageCatsSet = {}
for _, meteor in ipairs(comets) do
local curr, cats = p._main(meteor.data, meteor.code)
table.insert(infos, {
label = curr['名称'],
data = curr
})
for _, cat in ipairs(cats) do
pageCatsSet[cat] = true
end
end
-- 分类
local pageCats = {}
if not (args.namespace or args.nocat) then
for cat, _ in pairs(pageCatsSet) do
table.insert(pageCats, cat)
end
table.sort(pageCats)
end
if args.debug then
mw.logObject(infos, "infos")
mw.logObject(pageCats, "pageCats")
end
local infoboxTitle = args.pagename
return infobox.main(infoboxTitle, infos) .. table.concat(pageCats, "")
end
return p