Originally Posted by
Kevkul
I'm sure it can be done more elegantly, but this seems to work:
Code:
local function shorten(s)
return s:gsub("(%w+%s)", function(w) return w:sub(1,1) .. ". " end)
end
local name = shorten(Name(unit))
local tot = ""
local colon = ""
if Name("targettarget") ~= "Target's target" then
colon = ": "
tot = shorten(Name("targettarget"))
end
local r1, g1, b1, r2, g2, b2 = 0
if UnitIsPlayer(unit) then
r1, g1, b1 = ClassColor(unit)
else
r1, g1, b1 = HostileColor(unit)
end
if UnitIsPlayer("targettarget") then
r2, g2, b2 = ClassColor("targettarget")
else
r2, g2, b2 = HostileColor("targettarget")
end
return '|cff%02x%02x%02x%s|r%s|cff%02x%02x%02x%s', r1, g1, b1, name, colon, r2, g2, b2, tot
I was going to say that I wish I'd saved my LuaTexts somewhere, but I didn't know about the gsub function the last time I wrote it and this is way shorter.