Module:Inventory icon

From CivWiki
Revision as of 21:19, 23 January 2024 by Lodish (talk | contribs) (Created page with "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 if file:match( '%.gif$' ) or file:match( '%.png$' ) then file = 'Invicon ' .. file else file = 'Invicon ' .. file .. '.png' end return '32x32px|link=' .. ( link or '' ) .. '|class=pixel-image|' .. ( title or '' ) .. '' end return p")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Usage

Used by {{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
	
	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 '' ) .. '|class=pixel-image|' .. ( title or '' ) .. ']]'
end

return p