Module:Ability

De Inkipédia

Displays an inline gear ability icon with a text link.

Usage

{{Ability|<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:
  • S for Splatoon
  • S2 for Splatoon 2
  • S3 for Splatoon 3
name Unnamed Required The English name of the ability.
  • ? can be used to get the no-ability question mark.
size Unnamed Optional The pixel width for the icon. The default size is 24. Required if icononly is specified.
icononly Unnamed Optional. If present, the text label will be omitted.

Examples

Markup

* {{Ability|S|?}}
* {{Ability|S|Ink Saver (Main)}}
* {{Ability|S|Ink Saver (Main)|32}}
* {{Ability|S2|Ink Saver (Main)|32|icononly}}
* {{Ability|S3|Ink Saver (Main)|32|icononly}}

Output


local p = {}
local gameShortened = require("Module:GameShortened")
local francais = require("Module:Français")

function p.main(frame)
    local args = frame:getParent().args
    local name = args["name"] or args[1]
    local size = args["size"] or args[2]
    local icononly = args["icononly"] ~= nil or args[2] == "icononly" or args[3] == "icononly"
    return p.getAbilityIcon(name, size, icononly)
end

function p.getAbilityIcon(name, size, icononly)
    local result = "Neutral"
    local linkText = name
    
    if name == nil then name = "" end
    if size == nil then size = "24" end

    if name == "?" then
        linkText = "Gear ability"
        result = "[[File:Ability_Locked.png|" .. size .. "px|link=" .. linkText .. "]]"
    elseif name ~= "Neutral" then
        if name == "Recon" then
            linkText = "Recon (ability)"
        end

        local translatedLinkText = francais.getBonus(linkText) or linkText

        result = "[[File:Ability_" .. name .. ".png|" .. size .. "px|link=" .. translatedLinkText .. "]]"

        if not icononly then
            result = result .. "&#32;[[" .. translatedLinkText .. "]]"
        end
    elseif name == "Neutral" then    --MAINTENANCE
        result = result .. " [[Category:Neutral gear ability call]]"
    end

    return result
end

return p