View Single Post
Unread 12-22-12, 05:36 AM   #3
gmarco
Premium Member
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 97
Hi, thanks for your reply...

The code is this:

Lua Code:
  1. local prgname = "|cffffd200autopsy|r"
  2.  
  3. local function color(destName)
  4.    if not UnitExists(destName) then return string_format("|cffff0000%s|r", destName) end
  5.    local _, class = UnitClass(destName)
  6.    local color = _G["RAID_CLASS_COLORS"][class]
  7.    return string_format("|cff%02x%02x%02x%s|r", color.r*255, color.g*255, color.b*255, destName)
  8. end
  9.  
  10.         -- begins code on parsing CLEU
  11.  
  12.     local timeStamp, event, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _, prefixParam1, prefixParam2, _, suffixParam1, suffixParam2 = ... 
  13.    
  14.     -- proceed with CLEU handling
  15.     if not playerGUID then
  16.         playerGUID = UnitGUID("player")
  17.     end
  18.    
  19.     if destGUID == playerGUID or (destName and UnitClass(destName)) then
  20.  
  21.     -- prevent the case the sourceName is nil (sometimes it is happened)
  22.     sourceName = sourceName or "Someone"
  23.    
  24.     if event == "SWING_DAMAGE" then
  25.             if prefixParam2 > 0 then
  26.                 print(string_format("%s: [%s] killed [%s] with %s Melee overkill %s", prgname, sourceName, color(destName), prefixParam1, prefixParam2))
  27.                 autopsy_msg = string_format("autopsy: [%s] killed [%s] with %s Melee overkill %s", sourceName, destName, prefixParam1, prefixParam2)
  28.                 SendChatMessage(autopsy_msg, autopsy_chn)
  29.             end
  30.  
  31.          -- proceed with other code and damage types...

The print() works fine and I think I can use as a self output.
The SendChatMessage is not able to to color both the "prgname" nor the color(destName) ...

The only problem of this approach is that I have to deal with 2 different string format for the output if I'd like to mantain the colors in the "self" output.

Btw if can't be solved it is not a problem, so ... :-)

Thanks very much for your kind reply.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
gmarco is offline   Reply With Quote