Module:GameFromAbbreviation: Difference between revisions
From Inkipedia, the Splatoon wiki
m (corrected comment) |
Yoshifan52 (talk | contribs) m (Protected "Module:GameFromAbbreviation": Widely transcluded template ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite))) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local fullName = { | |||
['OE'] = "Octo Expansion", | |||
['SR'] = "Salmon Run", | |||
['SO'] = "Side Order", | |||
['S'] = "Splatoon", | |||
['S1'] = "Splatoon", | |||
['S2'] = "Splatoon 2", | |||
['S3'] = "Splatoon 3", | |||
} | |||
function p.getFullName(abbr, default) | function p.getFullName(abbr, default) | ||
abbr = string.upper(abbr) | abbr = string.upper(abbr) | ||
-- If an invalid abbreviation is used (thus nil would be returned), default will be used | -- If an invalid abbreviation is used (thus nil would be returned), default will be used | ||
return fullName[abbr] or default | return fullName[abbr] or default |
Latest revision as of 07:10, 11 February 2024
Usage
{{GameFromAbbreviation|<game>|<default>}}
game
|
Named or first positional, required | The game's abbreviation (case insensitive). The following abbreviations are handled:
If an invalid abbreviation is used, the | |||
default
|
Named or second positional, optional | If the game argument was not matched, uses this instead. |
See Also
- Module:GameShortened (whom this is a fork of)
local p = {} local fullName = { ['OE'] = "Octo Expansion", ['SR'] = "Salmon Run", ['SO'] = "Side Order", ['S'] = "Splatoon", ['S1'] = "Splatoon", ['S2'] = "Splatoon 2", ['S3'] = "Splatoon 3", } function p.getFullName(abbr, default) abbr = string.upper(abbr) -- If an invalid abbreviation is used (thus nil would be returned), default will be used return fullName[abbr] or default end -- main to extract arg from frame function p.main(frame) local args = frame:getParent().args local game = args['game'] or args[1] local default = args['default'] or args[2] return p.getFullName(game, default) end return p --Forked from Module:GameShortened (by Slate)