« Module:Ability » : différence entre les versions

De Inkipédia
mAucun résumé des modifications
mAucun résumé des modifications
Ligne 13 : Ligne 13 :


function p.getAbilityIcon(game, name, size, icononly)
function p.getAbilityIcon(game, name, size, icononly)
local result = "Neutral"
    local result = "Neutral"
local linkText = name
    local linkText = name
    local gameShortened = require("Module:GameShortened")
game = gameShortened.getGame(game)
    local translatedBonus = require("Module:français").translatedBonus
if name == nil then name = "" end
if size == nil then size = "24" end


if name == "?" then
    game = gameShortened.getGame(game)
linkText = "Gear ability"
    if name == nil then name = "" end
result = "[[File:" .. game .. "_Ability_Locked.png|" .. size .. "px|link=" .. linkText .. "]]"
    if size == nil then size = "24" end
elseif name ~= "Neutral" then
 
    -- Translate specific ability names if available
    if name == "?" then
    if translatedBonus[name] ~= nil then
        linkText = "Gear ability"
        linkText = translatedBonus[name]
        result = "[[File:" .. game .. "_Ability_Locked.png|" .. size .. "px|link=" .. linkText .. "]]"
    end
    elseif name ~= "Neutral" then
        local translatedName = p.getBonus(name)
 
        -- Translate specific ability names if available
        if translatedBonus[translatedName] ~= nil then
            linkText = translatedBonus[translatedName]
        end


    -- Handle special cases like "Recon"
        -- Handle special cases like "Recon"
    if name == "Recon" and translatedBonus["Recon (ability)"] ~= nil then
        if translatedName == "Recon" and translatedBonus["Recon (ability)"] ~= nil then
        linkText = translatedBonus["Recon (ability)"]
            linkText = translatedBonus["Recon (ability)"]
    end
        end


    result = "[[File:" .. game .. "_Ability_" .. name .. ".png|" .. size .. "px|link=" .. linkText .. "]]"
        result = "[[File:" .. game .. "_Ability_" .. name .. ".png|" .. size .. "px|link=" .. linkText .. "]]"


    if not icononly then
        if not icononly then
        result = result .. " [[" .. linkText .. "]]"
            result = result .. " [[" .. linkText .. "]]"
        end
    elseif name == "Neutral" then
        result = result .. " [[Category:Neutral gear ability call]]"
     end
     end


elseif name == "Neutral" then --MAINTENANCE
    return result
result = result .. " [[Category:Neutral gear ability call]]"
end
 
return result
end
end


return p
return p

Version du 17 mai 2024 à 13:23

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

  • Erreur Lua à la ligne 28 : attempt to call field 'getBonus' (a nil value).
  • Erreur Lua à la ligne 28 : attempt to call field 'getBonus' (a nil value).
  • Erreur Lua à la ligne 28 : attempt to call field 'getBonus' (a nil value).
  • Erreur Lua à la ligne 28 : attempt to call field 'getBonus' (a nil value).

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

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

function p.getAbilityIcon(game, name, size, icononly)
    local result = "Neutral"
    local linkText = name
    local gameShortened = require("Module:GameShortened")
    local translatedBonus = require("Module:français").translatedBonus

    game = gameShortened.getGame(game)
    if name == nil then name = "" end
    if size == nil then size = "24" end

    if name == "?" then
        linkText = "Gear ability"
        result = "[[File:" .. game .. "_Ability_Locked.png|" .. size .. "px|link=" .. linkText .. "]]"
    elseif name ~= "Neutral" then
        local translatedName = p.getBonus(name)

        -- Translate specific ability names if available
        if translatedBonus[translatedName] ~= nil then
            linkText = translatedBonus[translatedName]
        end

        -- Handle special cases like "Recon"
        if translatedName == "Recon" and translatedBonus["Recon (ability)"] ~= nil then
            linkText = translatedBonus["Recon (ability)"]
        end

        result = "[[File:" .. game .. "_Ability_" .. name .. ".png|" .. size .. "px|link=" .. linkText .. "]]"

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

    return result
end

return p