Quantcast WoWInterface - View Single Post - make blizz frames appear when damaged
View Single Post
08-01-18, 03:24 AM   #6
joeyo
An Aku'mai Servant
Join Date: Jan 2012
Posts: 31
Originally Posted by Theroxis View Post
Take a look at the way ImprovedBlizzardUI handles this:

https://github.com/kaytotes/Improved...yer.lua#L25-39

This block of code decides whether or not to hide the Blizzard PlayerFrame;

The variable "hide" comes from their event handler here:

https://github.com/kaytotes/Improved...er.lua#L84-114

And the event(s) that will fire that function are here:

https://github.com/kaytotes/Improved...r.lua#L122-130


Basically, they fire an event any appropriate time (PLAYER_ENTERING_WORLD for initial login, and any time the player sees a loading screen, any time you enter/exit a vehicle, etc..) to check the status of the PlayerFrame healthbar.
Then, inside that function they check a couple of small things:
Do you have a target?
Are you regenerating heatlh?
If either of these things are true, then it DOES NOT hide the frame.
If BOTH of these things are FALSE, then it DOES hide the frame.

The actual hiding function checks a couple of other things once more:

Is your health actually full? (It's actually possible for you to NOT be at max health, be OUT of combat and NOT have Regen for a brief period, this works around that.)
Is your target actually empty? (It's possible to have targetted something between when the event handler fired and when the hide function runs, this fixes that)

As a small caveat, you could add a function to toggle a variable between true and false. Then your macro to force show the unit frame could use /run FunctionName(); to toggle that variable, and you could add a conditional to the hide code that makes sure that variable is false before hiding.
So this looks to be the exact function Iím looking for I just have no idea how I would go about having a simple addon Lua for just that function and not have the rest of the stuff in that add on
  Reply With Quote