I have a small problem with my OnUpdate timers. When I alt tab out of WoW my timers freeze and when I come back they start ticking again. I made this addon to keep track of the time until a battleground starts with an OnUpdate function but if I alt tab during this time it gets completely out of sync. :(
Is it possible to fix this?
local starttime = time() + <how many seconds you want your timer to run for>
frame:SetScript("OnUpdate", function(frame)
if time() > starttime then
frame:SetScript("OnUpdate", nil)
--stuff to run when the timer finishes
end
end)
Something like that, or you could just use AceTimer.
Here is my test code, if you could show me how to modify it to use time() instead of elapsed then perhaps I would understand it better.
local f = CreateFrame("Frame")
local elapsedTime = 0
local counter = 10
local function countdownTimer(self, elapsed)
elapsedTime = elapsedTime + elapsed
if elapsedTime > 1 then
if counter > 0 then
print("countdown: " .. counter)
elapsedTime = 0
counter = counter - 1
else
print("reached 0")
f:SetScript("OnUpdate", nil)
end
end
end
f:SetScript("OnUpdate", countdownTimer)
I have a small problem with my OnUpdate timers. When I alt tab out of WoW my timers freeze and when I come back they start ticking again. I made this addon to keep track of the time until a battleground starts with an OnUpdate function but if I alt tab during this time it gets completely out of sync. :(
Is it possible to fix this?
This is a known bug when you are running WoW in fullscreen mode. switch to windowed mode to fix.
Windowed fullscreen, the only mode you should *ever* use.
Why? I thought you get an FPS boost when not using windowed mode?
Anyway when alt-tabbed out WoW doesn't run the OnUpdate handlers while in fullscreen mode so instead of telling the time relative to each OnUpdate you would want to get the fixed time using time() or GetTime().
e.g.
local startTime = GetTime()
local counter = 10
CreateFrame("Frame"):SetScript("OnUpdate", function(f)
local currentTime = GetTime()
if currentTime - 1 > startTime then
for i = counter, counter - math.floor((currentTime - 1) - startTime), -1 do
if i > 0 then
print("countdown: " .. i)
startTime = GetTime()
counter = counter - 1
else
print("reached 0")
f:SetScript("OnUpdate", nil)
end
end
end
end)
Why? I thought you get an FPS boost when not using windowed mode?
Not necessarily. You have to actually try to see if it actually provides any improvement to FPS, especially if you run dual screen (on Dual screen, you are still rendering both the game and windows on the second screen, and may not get any improvement).
The above code doesn't work, it prints out the numbers from 10 to 0 within 1 sec.
Works for me, just tested in WoWLua, if your on about starting the timer then minimising WoW waiting 10 seconds and then having it print numbers 10 to 0 within 1 sec then this is to be expected, as the timer has to catch up.
Not necessarily. You have to actually try to see if it actually provides any improvement to FPS, especially if you run dual screen (on Dual screen, you are still rendering both the game and windows on the second screen, and may not get any improvement).
I actually get a better framerate in windowed mode than in fullscreen mode, with a single-monitor setup. This has held true through several combinations of motherboards, processors, and video cards.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Is it possible to fix this?
elapsedTime = elapsedTime + time() doesn't seem to work
Something like that, or you could just use AceTimer.
elapsedTime = time() - timeFromLastUpdate
and then...
timeFromLastUpdate = time()
Here is my test code, if you could show me how to modify it to use time() instead of elapsed then perhaps I would understand it better.
This is a known bug when you are running WoW in fullscreen mode. switch to windowed mode to fix.
Why? I thought you get an FPS boost when not using windowed mode?
Anyway when alt-tabbed out WoW doesn't run the OnUpdate handlers while in fullscreen mode so instead of telling the time relative to each OnUpdate you would want to get the fixed time using time() or GetTime().
e.g.
Not necessarily. You have to actually try to see if it actually provides any improvement to FPS, especially if you run dual screen (on Dual screen, you are still rendering both the game and windows on the second screen, and may not get any improvement).
Works for me, just tested in WoWLua, if your on about starting the timer then minimising WoW waiting 10 seconds and then having it print numbers 10 to 0 within 1 sec then this is to be expected, as the timer has to catch up.
Thanks a lot for the help!
I actually get a better framerate in windowed mode than in fullscreen mode, with a single-monitor setup. This has held true through several combinations of motherboards, processors, and video cards.