Quantcast Smart way to register unit aura event for all raid members - WoWInterface
Thread Tools Display Modes
02-25-19, 03:51 PM   #1
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Smart way to register unit aura event for all raid members

Hello! So i am reaching out for some smart advice to register every raid member in a a raid on the unit_aura event.

Some quick info about the addon: I am gathering each raid members debuffs (UnitDebuff()) and checking if a debuff on the raid member exists in my pre defined list of debuffs that i am checking.

How would a smart way be to register all the raid members on the event "UNIT_AURA" for this?

What i currently have is something along this line

Lua Code:
  1. local frame = CreateFrame("FRAME", nil); -- Frame that register various events in the world
  2.  
  3. function frame:UNIT_AURA()
  4.     -- check if every raid member inside my raid have any of the following debuffs in my debuff list
  5. end
  6.  
  7. function frame:PLAYER_ENTERING_WORLD(event, ...)
  8.     if(IsInRaid("player")) then --
  9.         for i = 1, MAX_RAID_MEMBERS do --(40)
  10.             if(UnitName("raid"..i) ~= nil) then
  11.                 frame:RegisterEvent("UNIT_AURA", "raid"..i)
  12.             end
  13.         end
  14.     end
  15. end
  16.  
  17.  
  18. frame:SetScript("OnEvent", function(self, event, ...)
  19.         self[event](self, event, ...)
  20.     end)
  21. frame:RegisterEvent("PLAYER_ENTERING_WORLD");

Would this be a good and smart way to register all the raid members under the event "UNIT_AURA" in order to check the raid members for debuffs? It is important for me to have the frame:UNIT_AURA() function executed whenever anything in regards to debuffs happends on whatever player in my raid. Kinds regards!

Last edited by wille480 : 02-25-19 at 03:54 PM.
  Reply With Quote
02-25-19, 05:00 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,086
Events starting with UNIT_ will pass the unit the event is for as the first parameter.

Lua Code:
  1. local Events = {}
  2. function Events.UNIT_AURA(self, ...)
  3.     local unit = ...
  4. -- check the units auras
  5. end
  6.  
  7. function Events.PLAYER_ENTERING_WORLD(self, ...)
  8.     local isInitialLogin, isReloadingUi = ...
  9. -- do whatever
  10. end
  11.  
  12. local frame = CreateFrame("FRAME", nil); -- Frame that register various events in the world
  13. frame:SetScript("OnEvent", function(self, event, ...)
  14.     Events[event](self, ...)
  15. end)
  16.  
  17. for k,_ in pairs(Events) do
  18.     frame:RegisterEvent(k)
  19. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Smart way to register unit aura event for all raid members

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