Advertisement
Guest User

Hiding PlayerFrame from Stuf Unit Frame

a guest
Aug 29th, 2016
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local hideFrame = CreateFrame("FRAME")
  2.  
  3. local function PEW_EventHandler(self, event, ...)
  4.     --when you LogIn or use /reload
  5.     if(event == "PLAYER_ENTERING_WORLD") then
  6.         --Make the PlayerFrame invisible at the start
  7.         Stuf.units.player:SetAlpha(0);
  8.        
  9.         --when you mouseover the PlayerFrame
  10.         Stuf.units.player:HookScript("OnEnter", function(self)
  11.             self:SetAlpha(1);
  12.         end);
  13.  
  14.         --when you stop mouseover the PlayerFrame
  15.         Stuf.units.player:HookScript("OnLeave", function(self)
  16.             if(not InCombatLockdown() and not UnitExists("target")) then
  17.                 self:SetAlpha(0);
  18.             end
  19.         end);
  20.  
  21.     --gets out-of-combat
  22.     elseif(event == "PLAYER_REGEN_ENABLED") then
  23.         Stuf.units.player:SetAlpha(0);
  24.  
  25.     --enters in combat
  26.     elseif(event == "PLAYER_REGEN_DISABLED") then
  27.         Stuf.units.player:SetAlpha(1);
  28.    
  29.     --target changes
  30.     elseif(event == "PLAYER_TARGET_CHANGED") then
  31.         if(not InCombatLockdown()) then
  32.             if(UnitExists("target")) then
  33.                 Stuf.units.player:SetAlpha(1);
  34.             else
  35.                 Stuf.units.player:SetAlpha(0);
  36.             end
  37.         end
  38.     end
  39. end
  40.  
  41. hideFrame:SetScript("OnEvent", PEW_EventHandler)
  42.  
  43. hideFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
  44. hideFrame:RegisterEvent("PLAYER_REGEN_ENABLED");
  45. hideFrame:RegisterEvent("PLAYER_REGEN_DISABLED");
  46. hideFrame:RegisterEvent("PLAYER_TARGET_CHANGED");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement