View Single Post
07-31-18, 10:20 PM   #5
Theroxis
A Fallenroot Satyr
Join Date: Jun 2018
Posts: 24
Originally Posted by joeyo View Post
I meant if I’m out of combat the playerframe will stay visible until I’m at full health again.

So what this does so far will hide it if I’m out of combat and show if I’m in combat or have a target.
I want to make it so that it also makes it stay visible if I’m not at full health.

I’m still new at writing code so if any knows how to add that to what I got I appreciate your efforts.
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.

Last edited by Theroxis : 07-31-18 at 10:26 PM.
  Reply With Quote