lua Code:
local addon = CreateFrame("Frame");
addon:RegisterEvent("PLAYER_LOGIN");
addon:RegisterEvent("PLAYER_REGEN_DISABLED");
addon:RegisterEvent("PLAYER_REGEN_ENABLED");
addon:RegisterEvent("PLAYER_STARTED_MOVING");
addon:RegisterEvent("PLAYER_STOPPED_MOVING");
addon:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN"
or event == "PLAYER_REGEN_DISABLED"
or event == "PLAYER_STOPPED_MOVING" then
if not UnitAffectingCombat("player") then
C_Timer.After(3, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0));
end;
else
UIParent:SetAlpha(1);
end;
if UnitAffectingCombat("player") then
UIParent:SetAlpha(1);
end;
end);
addon:SetScript("OnUpdate", function(self, elapsed)
local speed = GetUnitSpeed("player");
if speed ~=0 then
UIParent:SetAlpha(1);
else
if GetMouseFocus() then
if GetMouseFocus():GetName() ~= "WorldFrame" then
UIParent:SetAlpha(1);
else
if not UnitAffectingCombat("player") then
C_Timer.After(3, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0))
end;
end;
end;
end;
if UnitName("mouseover") then
UIParent:SetAlpha(1);
end;
end);
I also tried to work around the "timer" solution through C_Timer, but then I realized that the interaction was already happening after out of combat, but just delayed. The user must STAY idle for that amount of time in order for the interaction to be optimal.
It ended up working like a delayed time bomb. Very, very clunky.