Module:Aicon
Jump to navigation
Jump to search
This module implements {{Aicon}}
, supports invocations from other modules.
See template documentation for how to use this module from template.
Functions[edit source]
Other modules can invoke this module.
Exported function are listed below.
aIcon[edit source]
This function generates an icon instance in the style of legacy achievements or advancements in Java Edition.
Syntax: aIcon ( InvIcon, Background, State, Link, InvFile )
InvIcon
: The name should handled by Module:Inventory icon (not effective whenInvFile
is specified).Background
: The type of achievement or advancement this icon represents. Valid values:plain
,oval
,fancy
, andplain-mini
.State
: The status of achievement or advancement this icon represents. Valid values:raw
,worn
(valid only whenBackground
is notplain-mini
).Link
: Optional, the link target that the icon points to. No link by default.InvFile
: Optional, replacing the default icon (provided by Module:Inventory icon) as an image file (omittingFile:
prefix).
main[edit source]
This function is designed for template invocation, without extra parameter accepted, so not recomended to invoke it by other modules.
Dependencies[edit source]
[view] [edit] [history] [refresh]The above documentation is transcluded from Module:Aicon/doc.
local p = {}
local invIcon = require( 'Module:Inventory icon' ).icon
function p.aIcon( icon, background, state, link, file )
local f = mw.getCurrentFrame()
local argIcon = icon or 'Grass Block'
local argBackground = background or 'plain'
local argState = state or 'raw'
local argLink = link or ''
if ( argBackground ~= 'oval' ) and ( argBackground ~= 'fancy' ) and ( argBackground ~= 'plain-mini' ) then
argBackground = 'plain'
end
if argState ~= 'worn' then
argState = 'raw'
end
if ( argBackground == 'plain-mini' ) and ( argState ~= 'raw' ) then
argState = 'raw'
end
local iconBackground = '[[File:Advancement-' .. argBackground .. '-' .. argState .. '.png|link=' .. argLink .. '|class=pixel-image]]'
local iconContent
if file and file ~= '' then
iconContent = '[[File:' .. file .. '|link=' .. argLink .. '|32px|class=pixel-image]]'
else
iconContent = invIcon{ argIcon, link = argLink }
end
local outputContent = f:extensionTag{ name = 'span', content = iconContent, args = { class = 'module-Aicon-content' } }
local outputBackground = f:extensionTag{ name = 'span', content = iconBackground .. outputContent, args = { class = 'plainlinks module-Aicon-background' } }
return require( 'Module:TSLoader' ).call( 'Module:Aicon/styles.css' ) .. outputBackground
end
function p.main( f )
local args = f
local frame = mw.getCurrentFrame()
if f == frame then
args = require( 'Module:ProcessArgs' ).merge( true )
end
return p.aIcon( args[ 1 ], args[ 2 ] or args.bg, args[ 3 ] or args.state, args.link, args.file )
end
return p