I’m trying to find a way to get my raid frames to display names as shortened and also class colored.
I found a way to shorten names with this code:
return string.sub(Name(unit), 1, 6)
But I don’t know how to class color it. The code for the default class colored names is
local r,g,b = ClassColor(unit)
return ‘|cff%02x%02x%02x%s|r %s%s%s’,r,g,b,Name(unit),Angle(AFK(unit) or DND(unit))
Anyone have any idea how I can get the shortened names to show up as class colored?
I don’t know PitBull, maybe something like:
local _, classFilename = UnitClass(unit)
local color
if C_ClassColor then
color = C_ClassColor.GetClassColor(classFilename)
color = color:GenerateHexColor()
else
color = select(4, GetClassColor(classFilename))
end
local name = string.sub(Name(unit), 1, 6)
name = "|c"..color..name.."|r"
return "%s %s", name, Angle(AFK(unit) or DND(unit))
But given PB seems to have helper functions like Name() build in, it might have a class colour function as well.
Edited for Classic support.
2 Likes
Thanks for trying! Unfortunately everyone’s name is just “error” when using your code
Left off the quotes around the |r
Edited the code with fix.
It worked! Thank you so much!
1 Like