Advertisement
Savior

WA2: Name with class' color

Oct 9th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. function(...)
  2.     local GetAuraSourceName = function(aura)
  3.         local ColorizeString = function(subject, r, g, b)
  4.             r = r <= 255 and r >= 0 and r or 0
  5.             g = g <= 255 and g >= 0 and g or 0
  6.             b = b <= 255 and b >= 0 and b or 0
  7.             local color = string.format('%02x%02x%02x', r, g, b)
  8.             if not color or not subject then return end
  9.             return ('|cFF%s%s|r'):format(color,subject)
  10.         end
  11.         local GetClassColor = function(class)
  12.             local CLASS_COLORS = {
  13.                 ['Death Knight'] = {r=196, g=31, b=59,},
  14.                 ['Druid'] = {r=255, g=125, b=10,},
  15.                 ['Hunter'] = {r=171, g=212, b=115,},
  16.                 ['Mage'] = {r=105, g=204, b=240,},
  17.                 ['Monk'] = {r=0, g=255, b=150,},
  18.                 ['Paladin'] = {r=245, g=140, b=186,},
  19.                 ['Priest'] = {r=255, g=255, b=255,},
  20.                 ['Rogue'] = {r=255, g=245, b=105,},
  21.                 ['Shaman'] = {r=0, g=112, b=222,},
  22.                 ['Warlock'] = {r=148, g=130, b=201,},
  23.                 ['Warrior'] = {r=199, g=156, b=110,},
  24.             }
  25.             if CLASS_COLORS[class] then return CLASS_COLORS[class].r, CLASS_COLORS[class].g, CLASS_COLORS[class].b end
  26.         end    
  27.         local RAID_SIZE = 10 -- CHANGE THIS        
  28.         if not aura then return end
  29.         local auraName = aura
  30.         if type(aura) == 'number' then auraName = GetSpellInfo(aura) end
  31.         for i=1,RAID_SIZE do
  32.             local unitCaster = select(8, UnitAura('raid'..i, auraName))
  33.             if unitCaster and UnitExists(unitCaster) then return ColorizeString(UnitName(unitCaster), GetClassColor(UnitClass(unitCaster))) end
  34.         end    
  35.         local unitCaster = select(8, UnitAura('player', auraName))
  36.         if unitCaster and UnitExists(unitCaster) then return ColorizeString(UnitName(unitCaster), GetClassColor(UnitClass(unitCaster))) end
  37.     end
  38.     return GetAuraSourceName(select(5, ...))    
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement