How to pause a timer, and then resume it again?

Started by Cod0fDuty, Dec 16, 2021, 11:56 am

Previous topic - Next topic


I'm currently making a redstone timer program, but I can't seem to figure out a way to pause a timer by a redstone input, and then resuming it (not resetting the timer) after another redstone signal is detected.

I'm still pretty new to Lua and CC, and any help or suggestions would be greatly appreciated :)! Thanks in advance.


The best way to do a timer in CC is to use the os.startTimer function. This will return an ID that you will want to keep for two reasons, it's how you will recognise the timer when it goes off, and it will allow you to cancel the timer (which you will want to do).

You will also want to make a note of the time that you queued the timer and compare that you when you cancel/pause the timer. When you receive the second redstone signal you will want to queue a new timer with a shorter duration to account for the time that it has already run.