I am having issues with hiding my unitframes when I am out of combat. I want it to hide when I am at full health AND mana. So i tried this:
- Code: Select all
local djiFrame = CreateFrame("frame");
djiFrame:RegisterEvent("PLAYER_REGEN_ENABLED"); --leaving combat
djiFrame:RegisterEvent("PLAYER_REGEN_DISABLED"); --entering combat
djiFrame:SetScript("OnEvent", function()
if (event == "PLAYER_REGEN_ENABLED") then
djiFrame:RegisterEvent("UNIT_HEALTH");
elseif (event == "PLAYER_REGEN_DISABLED") then
DUF_PlayerFrame:Show();
DUF_TargetFrame:Show();
elseif (event == "UNIT_HEALTH") and UnitHealth ("player") == UnitHealthMax ("player") and UnitMana ("player") == UnitManaMax ("player")then
DUF_PlayerFrame:Hide();
DUF_PetFrame:Hide();
DUF_TargetFrame:Hide();
DUF_TargetOfTargetFrame:Hide();
djiFrame:UnregisterEvent("UNIT_HEALTH");
end
end)
It worked with just checking for max health, but now it doesn't really work. I just added the "and UnitMana..." but apparently you can't do that.
Any way to make it only go away when I have full health and mana?