Page 1 of 1

love.timer.getTime() resets?

Posted: Wed Jan 04, 2023 11:35 am
by Fabimawn
So I've been programming a lot with the Love2D framework lately which is really nice to work with. However I was always afraid to start implementing timers in my programs with the love.timer.getTime() function, since it's described on the site as: "Returns the value of a precise timer with an unspecified starting time.". It's kinda straight foreward, but also a vague explaination. If it returns time from an unspecified starting point, does that also mean that at one point the timer can reset and return a new starting time? or will it always keep going?
I want to know this, because if I compare the difference in time, and it suddenly resets back to around 0, the comparison will be faulty.
Can anyone explain me how the inner mechanics of the timer work, and if it resets, and if yes, what to do about it.

Re: love.timer.getTime() resets?

Posted: Wed Jan 04, 2023 12:13 pm
by slime
It always keeps going, you just always need to calculate the difference between a start and end time rather than assuming the time is always 0 at a certain point or whatever.*


* In love 11.4 it was changed to get set to 0 when the love.timer module is loaded. Before then, it was up to the OS (for example on some operating systems it would only be set to 0 when the computer is booted up.)

Re: love.timer.getTime() resets?

Posted: Wed Jan 04, 2023 12:23 pm
by darkfrei
It resets to 0 on the game starting only.

Re: love.timer.getTime() resets?

Posted: Wed Jan 04, 2023 10:36 pm
by Fabimawn
Thanks for th info!