Module:Infobox: Difference between revisions

Jump to navigation Jump to search
1,200 bytes removed ,  09:04, 23 May 2019
no edit summary
imported>Kittymmeow
(will be moved to mainspace after scribunto is installed)
 
imported>Kittymmeow
No edit summary
Line 8: Line 8:
if not imageArea and imageArea ~= 'none' then
if not imageArea and imageArea ~= 'none' then
local images = {}
local images = {}
local invImages = {}
local defaultImageSize = args.defaultimagesize or '150px'
local defaultImageSize = args.defaultimagesize or '150px'
args.image1 = args.image1 or args.image or 'title'
args.image1 = args.image1 or args.image or 'title'
args.image1size = args.image1size or args.imagesize
args.image1size = args.image1size or args.imagesize
args.invimage1 = args.invimage1 or args.invimage or 'title'
local imgCount = {}
local imgCount = {}
local invImgCount = {}
for k, v in pairs( args ) do
for k, v in pairs( args ) do
if type( k ) == 'string' then
if type( k ) == 'string' then
local image, num = k:match( '^(image)(%d+)$' )
local image, num = k:match( '^(image)(%d+)$' )
local invImage, invNum = k:match( '^(invimage)(%d+)$' )
if v:lower() ~= 'none' then
if v:lower() ~= 'none' then
if image then
if image then
table.insert( imgCount, tonumber( num ) )
table.insert( imgCount, tonumber( num ) )
elseif invImage then
table.insert( invImgCount, tonumber( invNum ) )
end
end
end
end
Line 58: Line 52:
images = table.concat( images, '\n' )
images = table.concat( images, '\n' )
if #invImgCount > 0 then
if images ~= '' then
table.sort( invImgCount )
imageArea = images .. '\n'
local slot
local invIds = mw.loadData( 'Module:InvSprite' ).ids
local invAliases = mw.loadData( 'Module:Inventory slot/Aliases' )
for k, v in ipairs( invImgCount ) do
local image = args['invimage' .. v]
if image == 'title' then
if invIds[title] or invAliases[title] then
image = title
else
image = false
end
end
if image == '----' then
table.insert( invImages, '</div><div style="padding-top:.5em">' )
elseif image then
if not slot then
slot = require( 'Module:Inventory slot' ).slot
end
table.insert( invImages, slot{ image, link = 'none' } )
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 = images .. '\n' .. invImages
else
else
imageArea = 'none'
imageArea = 'none'
Anonymous user

Navigation menu