WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Game event (https://www.wowinterface.com/forums/showthread.php?t=59772)

Hubb777 01-25-24 10:37 PM

Game event
 
Hi all. There is a game event.

1) And there are prescribed text tasks.
2) There is a date file that already contains all these texts.

How can I make an addon react when certain text appears on an event?

I can do this with emotion via CHAT_MSG_MONSTER_EMOTE and with NPC messages via CHAT_MSG_MONSTER_SAY. What to do with an event? I can do it if I write in the chat. What if you don’t write?

Screenshot of the event.

SDPhantom 01-25-24 11:13 PM

It depends on what tasks you want to do. Keep in mind things like moving, casting a spell, using abilities, etc are protected actions and can't be run autonomously.

Hubb777 01-25-24 11:59 PM

Quote:

Originally Posted by SDPhantom (Post 343247)
It depends on what tasks you want to do. Keep in mind things like moving, casting a spell, using abilities, etc are protected actions and can't be run autonomously.

Hello. I want this or that task to happen. A direction arrow appeared to show where to perform.

I think one of the lines is responsible for this:
DISPLAY_EVENT_TOASTS
DISPLAY_EVENT_TOAST_LINK
SCENARIO_UPDATE

Xrystal 01-26-24 05:58 AM

At the most basic, the following allows you to monitor specific events and handle what to do when they trigger. This code in a lua file and the addon's toc file will be a simple addon.

Just replace < EVENT # > tags with a particular event name and add the appropriate code. For example I am just printing the event name and it's arguments. Just add a new else if section for each new event you want to watch and react to.

But, like SDPhantom said, there are restrictions to what you are allowed to do.

Lua Code:
  1. local eventWatcher = CreateFrame("Frame")
  2.  
  3. local function OnEvent(self,event,...)
  4.     local args = { ... }
  5.    
  6.     if event == "< EVENT 1 >" then
  7.         -- What to do if this event triggers
  8.         print(event,...)
  9.  
  10.     elseif event == "< EVENT 2 >" then
  11.         -- What to do if this event triggers
  12.         print(event,...)
  13.  
  14.     end    
  15.    
  16. end
  17.  
  18. eventWatcher:SetScript( "OnEvent", OnEvent );
  19. eventWatcher:RegisterEvent( " < EVENT 1 >" );
  20. eventWatcher:RegisterEvent( " < EVENT 2 >" );


All times are GMT -6. The time now is 01:17 AM.

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