缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!
该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!
全站通知:
模块:信息框/小动物
刷
历
编
< 模块:信息框
跳到导航
跳到搜索
local infobox = require([[Module:信息框]])
local yesno = require("Module:Dev/Yesno")
local fstr = mw.ustring.format
local p = {}
local innerNodes = {
{
tag = 'image',
source = '图片',
children = {{tag = 'caption', source = '图片说明'}}
},
{
tag = 'data',
source = 'ID',
label = 'ID'
},
{
tag = 'data',
source = '尺寸',
label = '尺寸'
},
{
tag = 'data',
source = '装饰',
label = '[[File:图标_装饰.png|16px|link=]] 装饰'
},
{
tag = 'data', --
source = '寿命',
label = '寿命'
},
{
tag = 'data', --
source = '血量',
label = '血量'
},
{
tag = 'data', --
source = '死亡掉落',
label = '死亡掉落'
},
{
tag = 'group',
header = '生存',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = '舒适温度范围',
label = '舒适范围'
},
{
tag = 'data',
source = '存活温度范围',
label = '存活范围'
}, --
{tag = 'data', source = '需求空间', label = '需求空间'},
-- 掩埋状态似乎没有啥实际影响,先注释掉
-- {tag = 'data', source = '掩埋致死', label = '掩埋致死'},
-- {tag = 'data', source = '水下生存', label = '水下生存'},
{tag = 'data', source = '淹没致死', label = '淹没致死'}
}
},
{
tag = 'group',
header = '繁殖',
attr = {collapse = 'open'},
children = {
{tag = 'data', source = '可驯化', label = '可驯化'},
{tag = 'data', source = '孵化期', label = '孵化期'},
{tag = 'data', source = '成熟期', label = '成熟期'},
{tag = 'data', source = '产卵周期', label = '产卵周期'},
{tag = 'data', source = '产卵概率', label = '产卵概率'}
}
},
{
tag = 'group',
header = '食谱',
attr = {collapse = 'closed'},
children = {
{tag = 'data', source = '代谢'},
}
},
{
tag = 'group',
header = '代谢',
attr = {collapse = 'closed'},
children = {
{tag = 'data', source = '卡路里变化', label = '每周期代谢'},
{tag = 'data', source = '胃容量', label = '胃容量'},
{tag = 'data', source = '饥饿倒计时', label = '饥饿倒计时'},
}
},
{
tag = 'group',
header = '构成',
attr = {collapse = 'closed'},
children = {
{
tag = 'data',
source = '元素',
label = '主要元素'
},
{
tag = 'data',
source = '质量',
label = '质量'
},
{
tag = 'data',
source = '初始温度',
label = '初始温度'
}
}
},
{
tag = 'group',
header = '可用DLC',
attr = {collapse = 'open'},
children = {
{
tag = 'data',
source = '可用DLC'
}
}
}
}
-- test: = p.infoboxContent{['装饰值'] = 5, ['装饰半径'] = 1, ['寿命'] = 1}
function p.infoboxContent(args)
if args['寿命'] ~= nil then
args['寿命'] = fstr("%s [[周期]]", tostring(args['寿命']))
end
if args['舒适温度下限'] ~= nil and args['舒适温度上限'] ~= nil then
args['舒适温度范围'] = fstr("%s°C ↔ %s°C ", tostring(args['舒适温度下限']), tostring(args['舒适温度上限']))
end
if args['存活温度下限'] ~= nil and args['存活温度上限'] ~= nil then
args['存活温度范围'] = fstr("%s°C ↔ %s°C ", tostring(args['存活温度下限']), tostring(args['存活温度上限']))
end
if args['装饰值'] ~= nil and args['装饰半径'] ~= nil then
args['装饰'] = fstr("%s(范围:%s 格)", tostring(args['装饰值']), tostring(args['装饰半径']))
end
if args['需求空间'] ~= nil then
args['需求空间'] = fstr("%s 格", tostring(args['需求空间']))
end
if args['掩埋致死'] ~= nil then
args['掩埋致死'] = yesno(args['掩埋致死']) and '✔' or '✖'
end
if args['淹没致死'] ~= nil then
args['淹没致死'] = yesno(args['淹没致死']) and '✔' or '✖'
end
if args['代谢'] ~= nil then
local node = mw.html.create('div'):tag('small'):css{
['display'] = 'grid',
['grid-template-columns'] = 'repeat(4, auto)',
['grid-column-gap'] = '1em',
['justify-content'] = 'start',
['white-space'] = 'nowrap'
}:wikitext(args['代谢'])
args['代谢'] = tostring(node)
end
if args['可驯化'] ~= nil then
args['可驯化'] = yesno(args['可驯化']) and '✔' or '✖'
end
local generated = {}
for _, n in ipairs(innerNodes) do
local child = infobox.genNode(n, args)
if child ~= nil then table.insert(generated, child) end
end
return generated
end
-- test: = p.main('testTitle', {{data={['过冷'] = 5}}}, true)
--[[ test: = p.main('testTitle', {
{label = 'testlabel1', data = {['过冷'] = 5}},
{label = 'testlabel2', data = {['过冷'] = 5}}
}, true)
]]
function p.main(title, data, raw)
local contentNodes = nil
if #data == 1 then
contentNodes = p.infoboxContent(data[1].data)
else
local panelData = {}
for _, pData in ipairs(data) do
table.insert(panelData, {
label = pData.label,
content = p.infoboxContent(pData.data)
})
end
contentNodes = {infobox.panel(panelData)}
end
return infobox.infobox(title, contentNodes)
end
-- test: =p.demo{['装饰值'] = 5, ['装饰半径'] = 1, ['寿命'] = 1, ['掩埋致死'] = 1, raw=true}
function p.demo(frame)
local getArgs = require('Module:Dev/Arguments').getArgs
local args = getArgs(frame)
return p.main(args['标题'], {{data = args}}, args.raw)
end
return p