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

De Pikmin FR
fr>Fxfxfx0
Copie du module Color
 
m 7 versions importées
 
(6 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
local p = {}
local p = {}
local textColor = require('Module:TextColor')
local textColor = require('Module:Text color')


-- Function to handle the color text
-- Function to handle the color text

Dernière version du 9 avril 2025 à 21:37

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