Thread Tools Display Modes
Prev Previous Post   Next Post Next
10-20-16, 10:58 PM   #21
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
lua Code:
  1. local addon = CreateFrame("Frame");
  2. addon:RegisterEvent("PLAYER_LOGIN");
  3. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  4. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  5. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  6. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  7.  
  8. local function wait(seconds)
  9.   local start = os.time()
  10.   repeat until os.time() > start + seconds
  11. end
  12.  
  13. addon:SetScript("OnEvent", function(self, event, ...)
  14.  
  15.     if event == "PLAYER_LOGIN"
  16.     or event == "PLAYER_REGEN_DISABLED"
  17.     or event == "PLAYER_STOPPED_MOVING" then
  18.        
  19.         if not UnitAffectingCombat("player") then
  20.             wait(3)
  21.             if not UnitAffectingCombat("player") then
  22.                 C_Timer.After(1, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0));
  23.             end;
  24.         end;
  25.     else
  26.         UIParent:SetAlpha(1);
  27.     end;
  28.    
  29.     if UnitAffectingCombat("player") then
  30.         UIParent:SetAlpha(1);
  31.     end;
  32. end);
  33.  
  34. addon:SetScript("OnUpdate", function(self, elapsed)
  35.  
  36.     local speed = GetUnitSpeed("player");
  37.     if speed ~=0 then
  38.         UIParent:SetAlpha(1);
  39.     else
  40.         if GetMouseFocus() then
  41.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  42.                 UIParent:SetAlpha(1);
  43.             else
  44.                 if not UnitAffectingCombat("player") then
  45.                     wait(3)
  46.                     if not UnitAffectingCombat("player") then
  47.                         C_Timer.After(1, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0))
  48.                     end;
  49.                 end;
  50.             end;
  51.         end;
  52.     end;
  53.    
  54.     if UnitName("mouseover") then
  55.         UIParent:SetAlpha(1);
  56.     end;
  57. end);

And in the end I basically tried inserting a wait() function that just basically didn't work out in the end. That code doesn't work and does nothing when I log in.
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Hide UI automatically hide after not moving my mouse for 3 or so seconds?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off