Max Time sdk Timers

I'm developing on mac m1, no device so just simulator for now. Working on a game.

wondering if there is a known max time for a pd.timer?

That said I'm not thinking hours or days, necessarily, tho i could imagine use cases. But can a timer track, say, more than 10, 15, 20 minutes?

A related question, about if I have one of these longer timers going and the player decides to shut down. During the save and exit stages of program, can I somehow save the state of a timer and bring it back easily? Or should I just record the value of time left, then instantiate a new timer based on that.

I know this is testable but I dont particularly want to test how long the timers can run as... that could potentially be a very long test haha.

There doesn't appear to be any maximum enforced in the code (you can check yourself: CoreLibs/timer.lua is public). But let's see: the duration value is in milliseconds, and the largest signed integer value our 32-bit Lua implementation can represent is 2,147,483,647. In milliseconds that's equal to about 25 days.

It's only a theoretical maximum — reality may present other obstacles to running a timer for that long — but I'm pretty sure any realistic use case is covered.

1 Like

Forgot to answer this part. Yes, you should save your timer states if you plan to resume them. There's no shortcut for this, but it's not too difficult to do. playdate.timer.timeLeft is the number you need.

1 Like

thanks for all the info! :frog:

forgot i could poke around the libraries for questions like these :man_technologist:

appreciate the bit of math. 25-day timer haha 600 hours of gameplay timer. real-time farm sim :man_farmer::ear_of_rice:

1 Like