Module:Availability

From Inkipedia, the Splatoon wiki

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:
  • S2 Icon Octo Canyon.png Octo Canyon
  • S Icon Octo Valley.png Octo Valley
  • S2 Icon Grizzco.png Salmon Run
  • Splatfest Logo.png S2 Splatfest Logo.svg S3 Splatfest Logo.svg Splatfest
  • 7-Eleven Logo.png 7-Eleven
  • OE Icon Deepsea Metro.png Octo Expansion
  • S3 SplatNet Catalog.png Catalog
  • S3 SplatNet Wandercrust.png 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