Thread Tools Display Modes
03-24-05, 08:31 PM   #1
Striph
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 15
Combat Chat message hook

How do you hook into the combat chat message window and parse for a string, then display that to the top of the screen?
  Reply With Quote
04-01-05, 06:18 AM   #2
Armod
A Kobold Labourer
Join Date: Feb 2005
Posts: 1
It depends on what you're looking for really. There's a list of events that you can use at wowwikki Here.

You need to first register which events you want to use when the UI is loaded:

Code:
function MSC_OnLoad()

	this:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
             this:RegisterEvent("SPELLCAST_START");
	this:RegisterEvent("PLAYER_REGEN_DISABLED");
	this:RegisterEvent("PLAYER_REGEN_ENABLED");

end
After that you need to use the OnEvent inside your xml file to call the one in your .lua one.

Code:
      <OnEvent>
        MSC_OnEvent();
      </OnEvent>
Then you can code your .lua file with whatever you're searching for, this is a snippit of how I used it:

Code:
         if (event == "CHAT_MSG_SPELL_SELF_DAMAGE") then
            if (strfind( arg1, "Your")) then
               s, f, msg = string.find(arg1, "Your (.*) hits");
               if (msg == nil) then
                  return;
               end
               MSCMessageFrame:AddMessage(msg.."!", 1, 1, 0, 0.85, 0.001);
            end
The important line you need to look at there is
s, f, msg = string.find(arg1, "Your (.*) hits");

What that line does is check the text from the event that triggered the code and finds the first instance in the string that says "Your xxx hits" xxx being a certain skill/spell ie: Sinister Strike.

The brackets around .* are what tells the script to save whatever it finds inside, after that I checked to make sure that it wasn't an empty variable and sent it on it's way. Hope that helped.

If you want a good example of how to get information from the combat log, I suggest looking at the code for the Scrolling Combat Text (SCT) addon.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Combat Chat message hook

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off