Starting timer with a single command

Posted by Helium on Tue 05 Jul 2005 04:40 PM — 4 posts, 20,042 views.

#0
I have a timer and i would like to start and stop it by typing commands in the input.
How? I know nothing about scripting
USA #1
You can use EnableTimer to turn on and off timers, when you turn them on, you'll also want to use ResetTimer to reset their clock to zero.

You'll want to make an alias to turn it on and off, since that's easier than typing out a long script command.
Something like this (in VBScript):

<aliases>
  <alias
   match="^enabletimer (on|off)$"
   enabled="y"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>if (StrComp("%1","on",1)) then
 EnableTimer "timername", 1
 ResetTimer "timername"
 Note "timername enabled."
else
 EnableTimer "timername", 0
 note "timername disabled."
end if</send>
  </alias>
</aliases>


Obviously you'll need to either hardcode a 'real' timer name, or make it a wildcard in your alias (but that also requires you to remember the timername), like this:
match="^enabletimer (\w+) (on|off)$"
and then you'll have to change the %1 to %2, and change all the 'timername's to '%1'.

http://www.gammon.com.au/scripts/function.php?name=EnableTimer
http://www.gammon.com.au/scripts/function.php?name=ResetTimer
#2
Hmm that didn't make much sense to me, sorry.

But i found out how to start / stop timers with
/enabletimer "timer",1
also how to reset them.

however as you said a alias would be cool and i thought
it could be done without even touching scripting
but where shall i send the command?

sending it to world isn't working.
USA #3
You can't do it without touching scripting. the enable command requires scripting (thats what your / does).

You'll need to send to script, without the script prefix.

What my trigger does is match on 'enabletimer on', or 'enabletimer off', and then if it's "on" it enables and resets, and if it's "off" it disables. Instead of having to have two aliases. You could hardcode it if you wanted to get around the strcomp by just typing 1 and 0 for on and off, and then just sending that as the argument. And you'd just have to reset everything.

Something like this:
match: ^timeron (\d)
Enabletimer "timername", %1
ResetTimer "timername"

Of course, you could also add the wildcard for the timername.