WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Combat Chat message hook (https://www.wowinterface.com/forums/showthread.php?t=515)

Striph 03-24-05 08:31 PM

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?

Armod 04-01-05 06:18 AM

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.


All times are GMT -6. The time now is 10:01 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI