View Single Post
03-22-11, 05:47 AM   #10
daylesan
A Fallenroot Satyr
Join Date: Feb 2011
Posts: 22
The raid icon is correctly recognized if present, but another problem appeared.

Once recognized, the raid icon is added to the destName string which is then processed into a message to be shown in a variety of ways depending on the user settings. The problem is that I can't find a way to insert the raid icon in a manner that works for both SendChatMessage() and ChatFrame:AddMessage().

Thus the question is: can raid icons be added in a format that works for both types of messages?

The following way works for ChatFrame:AddMessage() but results in a LUA error stating
SendChatMessage(): Invalid escape code in chat message
LUA Code:
  1. RaidIconMaskToIcon = {
  2. [COMBATLOG_OBJECT_RAIDTARGET1] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET1, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp:0|t"),
  3. -- etc
  4. }

While the following way works with SendChatMessage(), it doesn't work with ChatFrame:AddMessage() (the {rt1} will not be replaced by the actual icon texture).

LUA Code:
  1. RaidIconMaskToIcon = {
  2. [COMBATLOG_OBJECT_RAIDTARGET1] = "{rt1}",
  3. -- etc
  4. }



Relevant code for review:

LUA Code:
  1. local bit_and = bit.band
  2. local RaidIconMaskToIcon = {
  3.     [COMBATLOG_OBJECT_RAIDTARGET1] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET1, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp:0|t"),
  4.     [COMBATLOG_OBJECT_RAIDTARGET2] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET2, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_2.blp:0|t"),
  5.     [COMBATLOG_OBJECT_RAIDTARGET3] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET3, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_3.blp:0|t"),
  6.     [COMBATLOG_OBJECT_RAIDTARGET4] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET4, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_4.blp:0|t"),
  7.     [COMBATLOG_OBJECT_RAIDTARGET5] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET5, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_5.blp:0|t"),
  8.     [COMBATLOG_OBJECT_RAIDTARGET6] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET6, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_6.blp:0|t"),
  9.     [COMBATLOG_OBJECT_RAIDTARGET7] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET7, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_7.blp:0|t"),
  10.     [COMBATLOG_OBJECT_RAIDTARGET8] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET8, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8.blp:0|t")
  11. }
  12. local msgTags = {}
  13.  
  14. function ezInterrupt:COMBAT_LOG_EVENT_UNFILTERED(_,_,event,sourceGUID,_,sourceFlags,_,destName,destFlags,spellID,_,_,extraID, ...)
  15.     if event == "SPELL_INTERRUPT" and bit_and(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) ~= 0 then
  16.         local raidIcon = RaidIconMaskToIcon[bit_and(destFlags, COMBATLOG_OBJECT_RAIDTARGET_MASK)]
  17.         if raidIcon then destName = string.format("%s%s", raidIcon, destName) end
  18.         msgTags["[spell]"] = GetSpellLink(extraID)
  19.         msgTags["[target]"] = destName
  20.         msgTags["[interrupt]"] = GetSpellLink(spellID) 
  21.         local msg = string.gsub(self.db.profile.customMessage, "%[%a+%]", msgTags)
  22.         if self.db.profile.enableWhispering and self.db.profile.whisperTarget ~= nil then SendChatMessage(msg, "WHISPER", nil, self.db.profile.whisperTarget ) end
  23.         if self.db.profile.enableCustomChannel and self.db.profile.customChannel ~= nil then SendChatMessage(msg, "CHANNEL", nil, self.db.profile.customChannel ) end  
  24.         if self.db.profile.enableSystemMessage then LAST_ACTIVE_CHAT_EDIT_BOX:GetParent():AddMessage(msg) end
  25.         if outputChannel then SendChatMessage(msg, outputChannel) end
  26.     end
  27. end

For clarity
self.db.profile.customMessage = "Interrupted [target]'s [spell] with [interrupt]"
outputChannel is either "SAY" "PARTY" "RAID" or false

Last edited by daylesan : 03-22-11 at 07:26 AM.
  Reply With Quote