- 致编者:请牢记我们的域名wiki.mcbe-dev.net!
- 致编者:欢迎加入本Wiki的官方交流QQ群或Discord服务器!
- 基岩版1.19.31现已发布!(了解更多)
- Inner Core现已支持Xbox模组联机!(了解更多)
- 如果您是第一次来到本Wiki,欢迎注册一个账户
- 点击顶部的“编辑”或“编辑源代码”按钮即可编辑当前页面
- 请知悉:在不登录时也可以编辑和新建页面,但是您当前的IP地址会记录在编辑历史中
Module:Infobox
来自Minecraft基岩版开发Wiki
local p = {}
function p.infobox(f)
local args = f
if f == mw.getCurrentFrame() then
args = require('Module:ProcessArgs').merge(true)
end
f = mw.getCurrentFrame()
local isSubBox = args.subbox
local title
local imageArea = args.imagearea
local subHeader = args.subheader
local footer = args.footer
if not isSubBox then
if args.title and args.title ~= 'none' then
title = args.title
local titleNode = mw.html.create('div')
:addClass('infobox-title')
:cssText(args.titlestyle)
:wikitext(title)
title = tostring(titleNode)
end
if imageArea == 'none' then
imageArea = nil
end
if not imageArea then
local images = {}
local invImages = {}
local defaultImageSize = args.defaultimagesize or '160px'
args.image1 = args.image1 or args.image
args.image1size = args.image1size or args.imagesize or defaultImageSize
args.invimage1 = args.invimage1 or args.invimage
local imgCount = {}
local invImgCount = {}
for k, v in pairs(args) do
if type(k) == 'string' then
local name, num = mw.ustring.match(k, '^(.*image)(%d+)$')
if mw.ustring.lower(v) ~= 'none' then
if name == 'image' then
table.insert(imgCount, tonumber(num))
elseif name == 'invimage' then
table.insert(invImgCount, tonumber(num))
end
end
end
end
table.sort(imgCount)
local animate = require('Module:Animate').animate
for _, v in ipairs(imgCount) do
local image = args['image' .. v]
local size = args['image' .. v .. 'size'] or defaultImageSize
if mw.ustring.match(image, ';') then
image = animate {image, size}
else
image = '[[File:' .. image .. '|' .. size .. ']]'
end
table.insert(images, '<div>' .. image .. '</div>')
end
images = table.concat(images, '\n')
if #invImgCount > 0 then
table.sort(invImgCount)
local slot = require('Module:Inventory slot').slot
for _, v in ipairs(invImgCount) do
local image = args['invimage' .. v]
if image == '----' then
table.insert(invImages, '</div><div style="padding-top:.5em">')
elseif image then
table.insert(invImages, slot {image, link = 'none', mod = args.mod})
end
end
if slot and #invImages > 0 then
invImages = '<div class="infobox-invimages"><div>' .. table.concat(invImages, '') .. '</div></div>'
else
invImages = ''
end
else
invImages = ''
end
if images ~= '' or invImages ~= '' then
imageArea = '<div class="infobox-imagearea">' .. images .. '\n' .. invImages .. '</div>'
else
imageArea = nil
end
else
imageArea = '<div class="infobox-imagearea">' .. imageArea .. '</div>'
end
if subHeader then
local subHeaderNode = mw.html.create('div')
:addClass('infobox-subheader')
:cssText(args.subheaderstyle)
:wikitext(subHeader)
subHeader = tostring(subHeaderNode)
end
if footer then
footer = '<div class="infobox-footer">' .. footer .. '</div>'
end
end
local rows = args.rows
if rows then
if isSubBox then
rows = '<div class="infobox-rows subinfobox">' .. rows .. '</div>'
else
rows = '<div class="infobox-rows">' .. rows .. '</div>'
end
end
if not (title or imageArea or subHeader or rows or footer) then
return ''
end
local styles = f:extensionTag {name = 'templatestyles', args = {src = 'Infobox/styles.css'}}
local html = {}
if not isSubBox then
html = {
'<div class="notaninfobox">',
title or '',
imageArea or '',
subHeader or '',
rows or '',
footer or '',
'</div>'
}
else
html = {rows}
end
return styles .. table.concat(html)
end
return p