Module:ColorText: Difference between revisions

From He is Coming Official Wiki
Benjiminio (talk | contribs)
mNo edit summary
Benjiminio (talk | contribs)
mNo edit summary
Line 26: Line 26:
end
end


-- Make the module callable without specifying "main"
return p
return setmetatable(p, {
    __call = function(_, frame)
        return p.main(frame)
    end
})

Revision as of 12:28, 7 November 2025

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

-- Module:ColorText
-- Returns inline colored spans for keywords
local p = {}

-- Keyword-to-color mapping
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"
}

-- Main function
function p.main(frame)
    local keyword = frame.args[1] or ""
    local color = colors[keyword:lower()] or "#888888" -- default gray
    return string.format('<span style="color:%s !important;">%s</span>', color, keyword)
end

return p