Skip to content

Instantly share code, notes, and snippets.

@obble

obble/hide.lua Secret

Last active October 23, 2015 13:08
Show Gist options
  • Save obble/c4d5509f869251acf9f7 to your computer and use it in GitHub Desktop.
Save obble/c4d5509f869251acf9f7 to your computer and use it in GitHub Desktop.
local frames = { DUF_PlayerFrame, -- table of frames you want to show/hide
UnitExists'target' and DUF_TargetFrame,
UnitExists'pet' and DUF_PetFrame,
UnitExists'targettarget' and DUF_TOTFrame, } -- etc.
local d = CreateFrame'Frame'
d:RegisterEvent'PLAYER_ENTERING_WORLD'
d:RegisterEvent'UNIT_HEALTH' d:RegisterEvent'UNIT_MANA'
d:SetScript('OnEvent', function()
if event =='PLAYER_ENTERING_WORLD' then
for _, v in pairs (frames) do v:Hide() end
d:UnregisterEvent'PLAYER_ENTERING_WORLD'
end
if arg1 ~= 'player' then return end
local hv = UnitHealth'player' local pv = UnitMana'player'
local hmax = UnitHealthMax'player' local pmax = UnitManaMax'player'
if UnitAffectingCombat'player' or (hv ~= hmax or pv ~= pmax) then
for _, v in pairs (frames) do v:Show() end
elseif hv == hmax and pv == pmax then
for _, v in pairs (frames) do v:Hide() end
end
end)
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment