love.timer.getTime() resets?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Fabimawn
Prole
Posts: 8
Joined: Wed Jan 04, 2023 11:28 am
Location: Lua

love.timer.getTime() resets?

Post 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.
User avatar
slime
Solid Snayke
Posts: 3142
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.timer.getTime() resets?

Post 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.)
User avatar
darkfrei
Party member
Posts: 1184
Joined: Sat Feb 08, 2020 11:09 pm

Re: love.timer.getTime() resets?

Post by darkfrei »

It resets to 0 on the game starting only.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
Fabimawn
Prole
Posts: 8
Joined: Wed Jan 04, 2023 11:28 am
Location: Lua

Re: love.timer.getTime() resets?

Post by Fabimawn »

Thanks for th info!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest