Thread: Game event
View Single Post
01-26-24, 05:58 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,937
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 >" );
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote