Module:ColorText: Difference between revisions

From He is Coming Official Wiki
Benjiminio (talk | contribs)
m (poorly) added case for 'thorn' (beyond 'thorns')
Benjiminio (talk | contribs)
m add default routing to main function (drops the requirement to specify 'main' when invoking)
Line 21: Line 21:
     local color = colors[keyword:lower()] or "#888888"
     local color = colors[keyword:lower()] or "#888888"
     return string.format('<span style="color:%s !important;">%s</span>', color, keyword)
     return string.format('<span style="color:%s !important;">%s</span>', color, keyword)
end
function p._default(frame)
    return p.main(frame)
end
end


return p
return p

Revision as of 09:13, 15 July 2026

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 = frame.args[1] or ""
    local color = colors[keyword:lower()] or "#888888"
    return string.format('<span style="color:%s !important;">%s</span>', color, keyword)
end

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

return p