Timers. Are we not able to set the time_left?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

Hi all,

I have a timer and I want to specify exactly the time left on it.

Currently due to some game logic requirements I’m:

  • starting timer
  • counting down towards 0
  • pausing the timer when required (making inactive)
  • rebuilding timer back towards its wait_time

The first part is all fine, but when trying to rebuild towards the wait_time I’m running into an issue.

I can’t find a way to slowly increment the timer back up again. I can set the wait_time, that’s fine, but when paused the timer still sits at the value it was at, then when I unpause the timer, it just continues counting down to 0 from where it was paused.

Setting the wait_time doesn’t do what I need as it keeps counting down from the paused value anyway (the get_time_left() value). Does anyone know of a way to set the actual time remaining?

My fingers and toes are crossed. Thanks a tonne… Rob

:bust_in_silhouette: Reply From: Zylann

If you want to reset the timer, you need to start it again:

timer.set_wait_time(new_time)
timer.start()

Thank you… and bummer… I have to change my logic a little now. Oh well, a learning experience. Shame we can’t just intercept and say “Set Time Remaining to X”. Much appreciated though. Thanks again.

Robster | 2016-08-23 01:55