Module:Weapon
De Inkipédia
Displays an inline weapon icon with a text link.
Usage
{{Weapon|<game>|<name>|<size>|<icononly>}}
Parameters
Parameter | Type | Status | Description |
---|---|---|---|
game | Unnamed | Required | The game that the ability belongs to. Must be one of the following:
|
category | Unnamed | Required | The type of weapon. Must be one of the following:
|
name | Unnamed | Required | The English name of the weapon.
|
size | Unnamed | Optional | The pixel width for the icon. The default size is 24. |
icononly | Unnamed | Optional | If present, the text label will be omitted. |
var | Named | Optional | If present, the variant name will be appended to the file name, to choose between different variants of the same weapon's icons. |
Examples
Markup
* {{Weapon|S|Special|Bomb Rush}} * {{Weapon|S|Special|Bomb Rush (Seeker)|48}} * {{Weapon|S2|Main|Splattershot|icononly}} * {{Weapon|S2|Main|Splattershot|48|icononly}} * {{Weapon|S2|Main|?}} * {{Weapon|S2|Main|??}} * {{Weapon|S3|Main|?}} * {{Weapon|S3|Main|??}} * {{Weapon|S3|Main|Splattershot|icononly}} * {{Weapon|S3|Main|Splattershot|48|icononly}} * {{Weapon|S|Sub|Splat Bomb|icononly}} * {{Weapon|S2|Sub|Splat Bomb|icononly}} * {{Weapon|S3|Sub|Splat Bomb|icononly}} * {{Weapon|S|Special|Bomb Rush Splat Bomb|icononly}} * {{Weapon|S|Special|Killer Wail}} * {{Weapon|S3|Main|Hero Shot Replica|var=2D Current|icononly}}
Output
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
- Erreur Lua à la ligne 66 : bad argument #3 to 'format' (string expected, got nil).
local p = {} local gameShortened = require("Module:GameShortened") -- Local function for switch-like behavior to get full name local function getFullName(name) local case_table = { ["Bomb Rush"] = "Bomb Rush Splat Bomb", ["Bomb Rush (Burst Bomb)"] = "Bomb Rush Burst Bomb", ["Bomb Rush (Splat Bomb)"] = "Bomb Rush Splat Bomb", ["Bomb Rush (Suction Bomb)"] = "Bomb Rush Suction Bomb", ["Bomb Rush (Seeker)"] = "Bomb Rush Seeker", ["Bomb Launcher"] = "Splat-Bomb Launcher", ["Hero Gear"] = "Hero Shot Level 1", ["?"] = "Random", ["??"] = "Random 2", ["Unknown"] = "Not Found" } return case_table[name] or name end -- Local function for switch-like behavior to get link local function getLink(name, gameShort) -- If name starts with Bomb Rush if name:find("^Bomb Rush") then return "Bomb Rush" end local case_table = { ["Bomb Launcher"] = "Splat-Bomb Launcher", ["Smallfry"] = "Smallfry (character)|Smallfry", ["Unarmed"] = "List of unarmed missions", ["?"] = gameShort == "S3" and "Salmon_Run_Next_Wave#Wildcard_rotation|Random" or "Salmon_Run#Wildcard_rotation|Random", ["??"] = gameShort == "S3" and "Salmon_Run_Next_Wave#Wildcard_rotation|Random Rare" or "Salmon_Run#Rare_weapon-only_rotation|Random Rare" } return case_table[name] or name end local function extractArg(args, namedKey, positionalIndex, defaultValue) return args[namedKey] or args[positionalIndex] or defaultValue end function p.main(frame) -- Extract args from frame local parentArgs = frame:getParent().args local icononly = parentArgs['icononly'] or parentArgs[4] == "icononly" or parentArgs[5] == "icononly" or false local size = parentArgs['size'] or (parentArgs[4] ~= "icononly" and parentArgs[4]) or (parentArgs[5] ~= "icononly" and parentArgs[5]) or "24" local args = { game = extractArg(parentArgs, 'game', 1, ""), name = extractArg(parentArgs, 'name', 3, ""), icononly = icononly, size = size, variant = extractArg(parentArgs, 'var', nil, "") } return p.getWeapon(args) end -- Main function function p.getWeapon(args) local gameShort = gameShortened.getGame(args.game) -- Construct the file name using getFullName() local fileName = string.format("%s_Weapon_%s_%s%s.png", gameShort, args.category, getFullName(args.name), (args.variant and args.variant ~= "" and ("_" .. args.variant) or "")) -- Construct the output local output = string.format('[[File:%s|%spx|link=%s]]', fileName, args.size or 24, getLink(args.name, gameShort)) if not args.icononly then -- Add textual representation output = output .. " [[" .. getLink(args.name, gameShort) .. "]]" end return output end return p