Wonderful. Thanks so much for the help! Just loaded it in and it works great!
One last question-- I copied/pasted that over to my target frame and changed all the "player" calls to "target" instead. Here's what it ended up as:
Code:
function()
local unit_name = UnitName("target")
local color = ""
if (select(2, UnitClass("target")) == "HUNTER") then
color = "|cFFABD473"
elseif (select(2, UnitClass("target")) == "DEATHKNIGHT") then
color = "|cFFC41F3B"
elseif (select(2, UnitClass("target")) == "MAGE") then
color = "|cFF69CCF0"
elseif (select(2, UnitClass("target")) == "DRUID") then
color = "|cFFFF7D0A"
elseif (select(2, UnitClass("target")) == "MONK") then
color = "|cFF00FF96"
elseif (select(2, UnitClass("target")) == "PALADIN") then
color = "|cFFF58CBA"
elseif (select(2, UnitClass("target")) == "PRIEST") then
color = "|cFFFFFFFF"
elseif (select(2, UnitClass("target")) == "ROGUE") then
color = "|cFFFFF569"
elseif (select(2, UnitClass("target")) == "SHAMAN") then
color = "|cFF0070DE"
elseif (select(2, UnitClass("target")) == "WARLOCK") then
color = "|cFF9482C9"
elseif (select(2, UnitClass("target")) == "WARRIOR") then
color = "|cFFC79C6E"
else color = "|CFFFFFFFF"
end
return color..unit_name
end
It works fine at first, but then it causes a massive error when I open the weakauras options. The error that pops up is:
Message: [string "return function()..."]:29: attempt to concatenate local 'unit_name' (a nil value)
Time: 01/15/15 03:00:46
Count: 159
Stack: [C]: ?
[string "return function()..."]:29: in function <[string "return function()..."]:1>
Interface\AddOns\WeakAuras\RegionTypes\text.lua:91: in function `UpdateCustomText'
Interface\AddOns\WeakAuras\WeakAuras.lua:5019: in function <Interface\AddOns\WeakAuras\WeakAuras.lua:5015>
I think it's trying to find my target's name, but since I don't have a target, it's coming back as an error. Is there a way to safeguard against this? Some way to return "..." or "Name Unknown" if it can't find the name?