Module:Inventory icon: Difference between revisions
Jump to navigation
Jump to search
(deprecate InvSprite - Operation Sprite Ender) |
No edit summary Tag: Manual revert |
||
(10 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
local title = args.title | local title = args.title | ||
local filePrefix,fileName = file:match("(.+):(.+)") | |||
if file:match( '%.gif$' ) or file:match( '%.png$' ) then | if file:match( '%.gif$' ) or file:match( '%.png$' ) then | ||
file = 'Invicon ' .. file | if filePrefix == nil then | ||
file = 'Invicon ' .. file | |||
else | |||
file = filePrefix .. 'Invicon ' .. fileName | |||
end | |||
else | else | ||
file = 'Invicon ' .. file .. '.png' | if filePrefix == nil then | ||
file = 'Invicon ' .. file .. '.png' | |||
else | |||
file = filePrefix .. 'Invicon ' .. fileName .. '.png' | |||
end | |||
end | end | ||
-- if file:match( '%.gif$' ) or file:match( '%.png$' ) then | |||
-- file = 'Invicon ' .. file | |||
-- else | |||
-- file = 'Invicon ' .. file .. '.png' | |||
-- end | |||
return '[[File:' .. file .. '|32x32px|link=' .. ( link or '' ) .. '|' .. ( title or '' ) .. '|class=pixel-image]]' | return '[[File:' .. file .. '|32x32px|link=' .. ( link or '' ) .. '|' .. ( title or '' ) .. '|class=pixel-image]]' | ||
end | end | ||
return p | return p |
Latest revision as of 07:26, 31 October 2023
This is the documentation page. It will be transcluded into the main module page. See Template:Documentation for more information
This code has been modified from its original version to provide better support for Inventory icons with custom namespaces.
Usage
Used by {{Inventory icon}}
.
fr:Module:Icône inventaire it:Modulo:Inventory icon
local p = {}
p.icon = function( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
end
local file = args[1]
local link = args.link
local title = args.title
local filePrefix,fileName = file:match("(.+):(.+)")
if file:match( '%.gif$' ) or file:match( '%.png$' ) then
if filePrefix == nil then
file = 'Invicon ' .. file
else
file = filePrefix .. 'Invicon ' .. fileName
end
else
if filePrefix == nil then
file = 'Invicon ' .. file .. '.png'
else
file = filePrefix .. 'Invicon ' .. fileName .. '.png'
end
end
-- if file:match( '%.gif$' ) or file:match( '%.png$' ) then
-- file = 'Invicon ' .. file
-- else
-- file = 'Invicon ' .. file .. '.png'
-- end
return '[[File:' .. file .. '|32x32px|link=' .. ( link or '' ) .. '|' .. ( title or '' ) .. '|class=pixel-image]]'
end
return p