Quantcast
WoWInterface - View Single Post - make better / BuffFrame:Hide();
View Single Post
09-26-20, 04:22 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,978
I'd just run BuffFrame:Hide() by itself. There really isn't a need to wait for an event to fire.
It really depends on the frame and what its original code does. Lots of frames show and hide themselves. Fortunately, BuffFrame does not.



-= Off-Topic =-
To respond to an event, you need to create a frame to listen for it. For readability, many people use a generic handler to redirect events to different functions stored in the frame's table.

Example:
Lua Code:
  1. local EventFrame=CreateFrame("Frame");--    Create our frame and assign it to a local variable called EventFrame
  2. EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD");--    Register our frame to listen for PLAYER_ENTERING_WORLD
  3. EventFrame:SetScript("OnEvent",function(self,event,...)--   Dynamic function to act as our script handler
  4.     if self[event] then self[event](self,event,...); end--  If we have a method stored in the frame's table, run it
  5. end);
  6.  
  7. function EventFrame:PLAYER_ENTERING_WORLD(event,...)
  8. --  Do Stuff
  9. end

I personally prefer one of the more efficient ways of handling events, but this is explaining what you've seen others do.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 09-26-20 at 04:25 PM.
  Reply With Quote