View Single Post
10-20-16, 10:52 PM   #18
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.  
  9. local addon = CreateFrame("Frame");
  10. addon:RegisterEvent("PLAYER_LOGIN");
  11. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  12. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  13. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  14. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  15.  
  16.  
  17. addon:SetScript("OnEvent", function(self, event, ...)
  18.  
  19.     if event == "PLAYER_LOGIN"
  20.     or event == "PLAYER_REGEN_DISABLED"
  21.     or event == "PLAYER_STOPPED_MOVING" then
  22.        
  23.         if not UnitAffectingCombat("player") then
  24.             UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0);
  25.         end;
  26.     else
  27.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  28.     end;
  29.    
  30.     if UnitAffectingCombat("player") then
  31.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  32.     end;
  33. end);
  34.  
  35. addon:SetScript("OnUpdate", function(self, elapsed)
  36.  
  37.     local speed = GetUnitSpeed("player");
  38.     if speed ~=0 then
  39.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  40.     else
  41.         if GetMouseFocus() then
  42.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  43.                 UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  44.             else
  45.                 if not UnitAffectingCombat("player") then
  46.                     UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0.1);
  47.                 end;
  48.             end;
  49.         end;
  50.     end;
  51.    
  52.     if UnitName("mouseover") then
  53.         UIFrameFadeIn(UIParent, 1, UIParent:GetAlpha(), 1);
  54.     end;
  55. end);
  • When showing the UI, it should be instantly showed with 100% opacity, no fade-in
  • There should be a wait time of 3 or 4 seconds, and then the UI fades over 2 seconds. This is a more smooth transition and works better with the 'soft AFK detection' interaction.
  Reply With Quote