Convert decimal classcolor into hex

Here's a small function that will convert player classcolor from decimal into hex and prints it in the chat with format "playername, level XX class".

Snippet

local function DecimalToHex(r,g,b)
    return string.format("|cff%02x%02x%02x", r*255, g*255, b*255)
end

local playername = UnitName("player")
local playerclass,PLAYERCLASS = UnitClass("player")
local playerlevel = UnitLevel("player")
local classcolor = RAID_CLASS_COLORS[PLAYERCLASS]
local r,g,b = classcolor.r,classcolor.g,classcolor.b
local classcolorhex = DecimalToHex(r,g,b)
print(classcolorhex..playername..", level "..playerlevel.." "..playerclass.."|r")
Posted by Mikma at Sun, 24 Oct 2010 08:02:34 +0000