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");
local function wait(seconds)
local start = os.time()
repeat until os.time() > start + seconds
end
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
wait(3)
if not UnitAffectingCombat("player") then
C_Timer.After(1, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0));
end;
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
wait(3)
if not UnitAffectingCombat("player") then
C_Timer.After(1, UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0))
end;
end;
end;
end;
end;
if UnitName("mouseover") then
UIParent:SetAlpha(1);
end;
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.