WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   make better / BuffFrame:Hide(); (https://www.wowinterface.com/forums/showthread.php?t=58224)

jlrm365 09-26-20 01:49 AM

make better / BuffFrame:Hide();
 
I found a brilliant UI addon, but it still shows the auras / buffs in the top right corner.
I'm not a coder, but read through the LUA of a few addons and found:
Code:

"BuffFrame:Hide();"
I was able to make that work with /run BuffFrame:Hide();
It seemed smart to put it into an addon, so came up with:
Code:

function events:PLAYER_ENTERING_WORLD()
        BuffFrame:Hide();
end

It was put into the correct toc and lua configuration, so that wasn't the problem.
Simply changing the lua to just that one thing - to just "BuffFrame:Hide();" (no more lines or words) - made it work.

The thing is that I'm sure that can't be the slickest / most friendly to the game way to do it.
I'd simply like to hide that Buff frame utterly and always. What would be the simplest way to use "BuffFrame:Hide();" to do so?

Thanks! :cool:

SDPhantom 09-26-20 04:22 PM

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.

jlrm365 09-26-20 05:22 PM

Quote:

Originally Posted by SDPhantom (Post 336902)
I'd just run BuffFrame:Hide() by itself. There really isn't a need to wait for an event to fire.

The response and extra info is appreciated.
I'll do as suggested, there, and keep the "addon" as it is.
Thanks.


All times are GMT -6. The time now is 06:56 AM.

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