Module:User:Colchester Overpass/RarityText
Appearance
local p = {}
local rarityMap = {
["og"] = { display = "OG", class = "og-animated" },
["brainrot god"] = { display = "Brainrot God", class = "brainrotGod-animated" },
["secret"] = { display = "Secret", class = "secret-animated" },
["admin"] = { display = "Admin", class = "admin-animated" },
["unknown"] = { display = "Unknown", class = "unknown-animated" },
["festive"] = { display = "Festive", class = "festive-animated" }
}
local function normalize(s)
if not s then return "common" end
return mw.text.trim(mw.ustring.lower(s))
end
local function ucfirst(s)
s = s or ""
return mw.language.getContentLanguage():ucfirst(s)
end
function p.main(frame)
local args = (frame:getParent() and frame:getParent().args) or frame.args
local rarityRaw = args.Rarity or args[1] or "Common"
local name = args.Name
local hover = args.Hover
local key = normalize(rarityRaw)
local entry = rarityMap[key]
local display = (entry and entry.display) or ucfirst(rarityRaw)
local class = (entry and entry.class) or ("rarity-color " .. key)
local title = hover or ("A " .. display .. " Item or Brainrot.")
local text = name or display
return string.format(
'<span class="%s" title="%s"><b>%s</b></span>',
class,
mw.text.nowiki(title),
mw.text.nowiki(text)
)
end
return p