Timers

raleighwalter
17 May 2021, 08:24

Can a timer be stopped with any player input, but be restarted after say 15 seconds after being stopped if there is no further player input?

Share some code if you can...:)


mrangel
17 May 2021, 09:02

Do you mean when the player types a command or clicks a link? It should possible, but would be a little unreliable on the online player because it depends how long it takes the player's input to reach the server.

I think that if you have a timer mytimer, you could create another timer to handle the delay and call it something like pausetimer, by making a turnscript doing something like:

realtimer = GetTimer ("mytimer")
DisableTimer (realtimer)
if (GetTimer ("pausetimer") = null) {
  create timer ("pausetimer")
  pt.interval = 15
  pt.script => {
    if (not realtimer = null) {
      if (not realtimer.enabled) {
        realtimer.trigger = game.timeelapsed + this.remaining
        realtimer.enabled = true
      }
    }
    this.enabled = false
  }
}
else {
  pt = GetTimer ("pausetimer")
}
EnableTimer (pt)
pt.remaining = realtimer.trigger - game.timeelapsed

jmnevil54
17 May 2021, 17:29

So you want a timer that goes off after 15 seconds, unless the player offers input?


jmnevil54
23 May 2021, 02:58

Here is my game code:

DisableTimer (Start Timer)
msg ("This stops the timer.")

Edit: Here is the screenshots!
https://imgur.com/pTd6Di4
https://imgur.com/T3wDB1Z


K.V.
23 May 2021, 05:29

DisableTimer (Start Timer)

My brain just got stuck in a while loop!


Hello, jmne!


jmnevil54
24 May 2021, 01:25

Hi KV!