Author Topic: How do I reset command when used multiple times?  (Read 960 times)

fightingblind

  • Newbie
  • *
  • Posts: 2
How do I reset command when used multiple times?
« on: January 21, 2022, 03:58:08 PM »
I have a command that listens to a key and when that key is pressed it gives me a 25 second timer then TTS me for reset. Problem is if I hit that key before the 25 second timer goes off, instead of resetting the command it starts it again simultaneously. (if I hit it 3 seconds apart, then the TTS will be 25 seconds, then 3 seconds). I'm trying to get it to reset this specific command and perform it when I hit the button again.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: How do I reset command when used multiple times?
« Reply #1 on: January 21, 2022, 04:07:05 PM »
One of the simplest methods may be to use two commands: One that does the actual timing, and one that triggers off of the keypress.

That way, you can use the "Stop Another Command" action to stop the timing command, and start a new instance.

E.G.
your "Timer" command could contain
Code: [Select]
Pause 25 seconds
Say, 'Timer elapsed'

and your triggered command could contain
Code: [Select]
Kill command, 'Timer'
Execute command, 'Timer'

Do note that due to optimization, the "Stopped command, 'Timer'" entry will only appear in the log after its pause has elapsed.

fightingblind

  • Newbie
  • *
  • Posts: 2
Re: How do I reset command when used multiple times?
« Reply #2 on: January 21, 2022, 04:17:16 PM »
Beautimus. Exactly what I needed.