Jump to content
Sign in to follow this  
Etel

Help with LUA for addon to hide frame when mana/health is below max.

Recommended Posts

Hi there, I have this addon I have made that hides (Alpha=0) the Player and Pet frames when mana or health is at max. However, it does not work on my Rogue, for which the frame still does not show even when energy is below max. Any help in solving this and/or input appreciated!

 

 

local f = CreateFrame("frame");
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("UNIT_MANA")
f:SetScript('OnEvent', function()
  if arg1 ~= "player" then return end


if UnitHealth("player") < UnitHealthMax("player") then
    PlayerFrame:SetAlpha(1)
    PetFrame:SetAlpha(1)
      
elseif UnitMana("player") < UnitManaMax("player") then
    PlayerFrame:SetAlpha(1)
    PetFrame:SetAlpha(1)


elseif UnitMana("player") < 100 then
    PlayerFrame:SetAlpha(1)
    PetFrame:SetAlpha(1)


elseif UnitHealth("player") == UnitHealthMax("player") then
    PlayerFrame:SetAlpha(0)
    PetFrame:SetAlpha(0)




  end
end)

 

Share this post


Link to post
Share on other sites

i dont have 1.12.1 client at the moment but try this.

local f = CreateFrame("frame");
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("UNIT_MANA")
f:SetScript('OnEvent', function()
if arg1 ~= "player" then return end


if UnitHealth("player") < UnitHealthMax("player") or UnitMana("player") < UnitManaMax("player") then
    PlayerFrame:SetAlpha(1)
    PetFrame:SetAlpha(1)  

elseif UnitHealth("player") == UnitHealthMax("player") and UnitMana("player") == UnitManaMax("player") then
    PlayerFrame:SetAlpha(0)
    PetFrame:SetAlpha(0)

  end
end)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×