Module:Availability: Difference between revisions

From Inkipedia, the Splatoon wiki
 
m (Protected "Module:Availability": Widely transcluded template ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
 
(3 intermediate revisions by 2 users not shown)
Line 38: Line 38:
         displayText = "Salmon Run Next Wave"
         displayText = "Salmon Run Next Wave"
     elseif name == "Octo Expansion" then
     elseif name == "Octo Expansion" then
         filename = "S2 Icon C.Q. Cumber.png"
         filename = "OE Icon Deepsea Metro.png"
         link = "Octo Expansion"
         link = "Octo Expansion"
         displayText = "Octo Expansion"
         displayText = "Octo Expansion"
Line 57: Line 57:
         end
         end
     else
     else
     -- Default case
     -- Default case: simply return the name as its displayText.
     filename = "S Ability Locked.png"
     -- This assumes the name already handles the icon.
        displayText = name
         return name
         link = name
     end
     end
      
      

Latest revision as of 07:09, 11 February 2024

Displays an inline item availability icon with a text link.

Parameters

availability Unnamed. The means by which an item is available. Pre-made options are:
  • Octo Canyon
  • Octo Valley
  • Salmon Run
  • Splatfest
  • 7-Eleven
  • Octo Expansion
  • Catalog
  • Wandercrust

However, it need not be one of these. If something not in this list is used, it is the caller's responsibility to handle the icon and link.

size Unnamed, optional. A Mediawiki image size parameter for the icon.
game Optional. The game that the Brand belongs to. The default value is "Splatoon". Must be one of the following:
  • Splatoon
  • Splatoon 2
icononly Optional. If present and "true", the text label will be omitted.

Examples

Markup

{{Availability}}
{{Availability|Octo Canyon}}
{{Availability|Octo Valley|48px}}
{{Availability|Splatfest|game=Splatoon 2}}
{{Availability|Salmon Run|icononly=true}}
{{Availability|{{NS}} [[Custom]] example}}

Output

Splatfest Splatfest

Octo Canyon Octo Canyon

Octo Valley Octo Valley

Splatfest Splatfest

Salmon Run

Nintendo Switch Custom example


local p = {}

function p.main(frame)
	local args = frame:getParent().args
    local name = args[1] or "Splatfest"
    local size = args[2] or "24px"
    local game = args['game'] or "Splatoon"
    local iconOnly = args['icononly'] or false
    return p.getAvailability(name, size, game, iconOnly)
end

function p.getAvailability(name, size, game, iconOnly)
    local filename, link, displayText
    
    if name == "7-Eleven" then
        filename = "7-Eleven Logo.png"
        link = "Gear#Promotional gear"
        displayText = "7-Eleven"
    elseif name == "CoroCoro Comic" then
        filename = "CoroCoro Comic Logo.png"
        link = "Gear#CoroCoro Comic Promotional Gear"
        displayText = "CoroCoro Comic"
    elseif name == "Octo Canyon" then
        filename = "S2 Icon Octo Canyon.png"
        link = "Octo Canyon (mode)"
        displayText = "Octo Canyon"
    elseif name == "Octo Valley" then
        filename = "S Icon Octo Valley.png"
        link = "Octo Valley (mode)"
        displayText = "Octo Valley"
    elseif name == "Salmon Run" then
        filename = "S2 Icon Grizzco.png"
        link = "Salmon Run"
        displayText = "Salmon Run"
    elseif name == "Salmon Run Next Wave" then
        filename = "S3 Icon Mr Grizz.png"
        link = "Salmon Run Next Wave"
        displayText = "Salmon Run Next Wave"
    elseif name == "Octo Expansion" then
        filename = "OE Icon Deepsea Metro.png"
        link = "Octo Expansion"
        displayText = "Octo Expansion"
    elseif name == "Return of the Mammalians" then
        filename = "S3 Icon Return of the Mammalians.png"
        link = "Return of the Mammalians"
        displayText = "Return of the Mammalians"
    elseif name == "Splatfest" then
        link = "Splatfest"
        displayText = "Splatfest"
        if game == "Splatoon 2" then
            filename = "S2 Splatfest Logo.svg"
        elseif game == "Splatoon 3" then
            filename = "S3 Splatfest Logo.svg"
        else
        	-- including Splatoon 1
            filename = "Splatfest Logo.png"
        end
    else
    	-- Default case: simply return the name as its displayText.
    	-- This assumes the name already handles the icon.
        return name
    end
    
    -- Generate the link and icon
    local imgTag = '[[File:' .. filename .. '|' .. size .. '|' .. displayText .. '|link=' .. link .. ']]'
    
    if iconOnly == "true" then
        return imgTag
    else
        return imgTag .. ' [[' .. link .. '|' .. displayText .. ']]'
    end
end

return p