Module:Weapon: Difference between revisions
From Inkipedia, the Splatoon wiki
(untested Template:Weapon implementation) |
Yoshifan52 (talk | contribs) m (Protected "Module:Weapon": Widely transcluded template ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite))) |
||
(13 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local gameShortened = require("Module:GameShortened") | |||
function | -- Local function for switch-like behavior to get full name | ||
local | 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", | ["Bomb Launcher"] = "Splat-Bomb Launcher", | ||
["Hero Gear"] = "Hero Shot Level 1", | ["Hero Gear"] = "Hero Shot Level 1", | ||
["?"] = "Random", | ["?"] = "Random", | ||
["??"] = "Random 2", | ["??"] = "Random 2", | ||
["Unknown"] = "Not Found" | |||
} | } | ||
return | return case_table[name] or name | ||
end | end | ||
function | -- 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 | local case_table = { | ||
["Bomb Launcher"] = "Splat-Bomb Launcher", | |||
["Smallfry"] = "Smallfry (character)|Smallfry", | |||
[ | |||
[ | |||
["Unarmed"] = "List of unarmed missions", | ["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 | |||
return | |||
end | end | ||
function p.main(frame) | function p.main(frame) | ||
local | -- 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, ""), | |||
category = extractArg(parentArgs, 'category', 2, ""), | |||
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 | end | ||
return p | return p |
Latest revision as of 07:12, 11 February 2024
Displays an inline weapon icon with a text link.
Usage
{{Weapon|<game>|<category>|<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
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, ""), category = extractArg(parentArgs, 'category', 2, ""), 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