Module:ColorText

From He is Coming Official Wiki
Revision as of 10:19, 15 July 2026 by Benjiminio (talk | contribs)

Documentation for this module may be created at Module:ColorText/doc

local p = {}

local colors = {
    attack = "#e74444",
    armor = "#4179ab",
    health = "#93c13e",
    speed = "#ffd569",
    acid = "#ccf61f",
    freeze = "#62abd4",
    poison = "#bbc44e",
    purity = "#62abd4",
    regeneration = "#9b4c51",
    riptide = "#5880cc",
    stun = "#ffd569",
    thorns = "#8a961f",
    thorn = "#8a961f"
}

function p.main(frame)
    local keyword = mw.text.trim(frame.args[1] or "")
    if keyword == "" then return "" end

    local color = colors[keyword:lower()] or "#888888"

    -- keep the visible text safe, but keep output inline (no paragraph markup)
    local safeText = mw.text.nowiki(keyword)

    -- Return a compact inline string (no mw.html objects, no extra whitespace)
    local out = '<span style="color:' .. color .. ' !important;">' .. safeText .. '</span>'

    return out
end

function p._default(frame)
    return p.main(frame)
end

return p