Module:Gear
From Inkipedia, the Splatoon wiki
Displays an inline gear item icon with a text link.
Usage
{{Gear|<game>|<category>|<name>|<size>|<icononly>}}
Parameters
Parameter | Type | Status | Description |
---|---|---|---|
game | Named or unnamed (first positional) | Optional, defaults to S | The game that the item belongs to. Must be one of the following:
|
category | Named or unnamed (second positional) | Optional, defaults to Headgear | The type of gear. Must be one of the following:
|
name | Named or unnamed (third positional) | Optional, defaults to White Headband | The English name of the item. |
size | Named or unnamed (fourth positional) | Optional | The pixel width for the icon. The default size is 24px. |
icononly | Named or unnamed (fourth or fifth positional) | Optional | If present, the text label will be omitted. |
mio | Named only | Optional | For manually overriding the icon with a different filename. This parameter is particularly helpful when an icon is missing and needs a temporary placeholder. 'mio' stands for manual icon override. |
Examples
Markup
* {{Gear}} * {{Gear|S|Clothing|Basic Tee}} * {{Gear|S2|Clothing|Basic Tee|64}} * {{Gear|S3|Clothing|Basic Tee|200px}} * {{Gear|S|Clothing|Basic Tee|64|icononly}} * {{Gear|S|Clothing|Basic Tee|icononly}} * {{Gear|S2|Clothing|Basic Tee|64|icononly}} * {{Gear|S|Shoes|Cream Basics|256|mio=S2 Gear Shoes Cream Basics.png}}
Output
local p = {} p.main = function (frame) -- Calculate the game parameter -- It's the first positional, or in the parameter named 'game' -- If game is not specified a default of S will be used local game = frame:getParent().args['game'] or frame:getParent().args[1] or 'S' -- Calculate the category parameter -- It's the second positional, or in the parameter named 'category' -- If category is not specified a default of Headgear will be used local category = frame:getParent().args['category'] or frame:getParent().args[2] or 'Headgear' -- Calculate the name parameter -- It's the third positional, or in the parameter named 'name' -- If name is not specified a default of White Headband will be used local name = frame:getParent().args['name'] or frame:getParent().args[3] or 'White Headband' -- Calculate the size -- It's the fourth positional if specified, or in the parameter named 'size' -- If size is not specified a default of 24px will be used local size = frame:getParent().args['size'] or frame:getParent().args[4] if size then if tonumber(size) then size = string.format("%dpx", tonumber(size)) else -- size is already a string, let's assume it's correct -- unless ofc we think the size is "icononly" -- (from icononly as 4th positional without a named size param) if size == "icononly" then size = "24px" -- Default value end end else size = "24px" -- Default value end -- Calculate if icononly -- It's the fourth or fifth positional if specified, or if a parameter named 'icononly' has value local icononly = frame:getParent().args['icononly'] or frame:getParent().args[4] == "icononly" or frame:getParent().args[5] == "icononly" -- Calculate manual image override 'mio' -- Named optional only local mio = frame:getParent().args['mio'] -- Put it all together local alt = icononly and name or '' local result = "[[File:" .. (mio or (game .. "_Gear_" .. category .. "_" .. name .. ".png")) .. "|" .. size .. "|link=" .. name .. "|alt=" .. alt .."]]" if not icononly then result = result .. " [[" .. name .. "]]" end return result end return p