Module:Color

De Pikmin FR
Version datée du 20 septembre 2024 à 12:52 par fr>Fxfxfx0 (1 version importée : Import de la majorité des modèles manquants)

Summary

Colors text the specified color.

{{Color|<The Text>|<The Color>|<ingame>}}

If ingame is present, the named color is passed to {{Text color|<color>}} to show in-game color, instead of using HTML notation

To color links, see {{Color-link}}

Examples

Code Result
{{color|Named Example|red}} 000000
{{color|In-Game Example|Orange S2|ingame}} 000000
{{color|Hex Example|#0055FF}} 000000

local p = {}
local textColor = require('Module:Text color')

-- Function to handle the color text
function p.main(frame)
    local args = frame:getParent().args
    local text = args[1] or ""
    local color = args[2] or ""
    local ingame = args[3] or ""

    -- Check if the color is supposed to be an in-game color
    if ingame == "ingame" then
        color = 'rgb('.. textColor.getColor(color) ..')'
    end

    return '<span style="color:' .. color .. '">' .. text .. '</span>'
end

return p