From WikiChip
Editing mirc/commands/timer

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
 
{{mirc title|/timer Command}}
 
{{mirc title|/timer Command}}
The '''/timer command''' can be used to create a general purpose timer. A timer is a way to execute code at some specific interval or time and delay. Timers can be named and unnamed. Unnamed timers will get the lowest numeric timer index available. Named timers are specifically useful if you need to recall that timer at a later period - to pause it, resume it, or simply reset it. Starting a timer with a name that already exists will override the old timer. Timers are not blocking command, they
+
The '''/timer command''' can be used to create a general purpose timer. A [[timer]] is a way to execute code at some specific interval or time and delay. [[Timers]] can be named and unnamed. Unnamed timers will get the lowest numeric timer index available. Named timers are specifically useful if you need to recall that timer at a later period - to pause it, resume it, or simply reset it. Starting a timer with a name that already exists will override the old timer. Timers only get execute on the main mIRC message loop. I.E. after the alias/event are complete.  
only get executed after the alias/event/etc is complete, losing the access to the local scope.
 
  
 
== Synopsis ==
 
== Synopsis ==
 
  /timers [off]
 
  /timers [off]
 
  /timer[n|name] [off]
 
  /timer[n|name] [off]
  /timer[n|name] [-cdeomhipPrzN] [time] <repetitions> <interval> <nowiki><code></nowiki>
+
  /timer[n|name] [-cdeomhiprzN] [time] <repetitions> <interval> <nowiki><code></nowiki>
  
 
== Switches ==
 
== Switches ==
Line 21: Line 20:
 
Manipulator
 
Manipulator
 
* '''-e''' - Executes the code associated with a timer (note: it decrease the number of repetition of the timer, probably resets the time counter as well)
 
* '''-e''' - Executes the code associated with a timer (note: it decrease the number of repetition of the timer, probably resets the time counter as well)
* '''-p''' - Pauses a timer, but the countdown is not paused, this switch should serve no real purpose because of the countdown weirdness, -P was added to pause correctly the countdown.
+
* '''-p''' - Pauses a timer
* '''-P''' - Makes a real pause of the timer, countdown included.
+
* '''-r''' - Resumes a timer
* '''-r''' - Resumes a timer paused with -p or -P
 
 
* '''-z'''N - Resets an online timer; N=2 resets total time, N=1, resets current time, and N=0 is the same as N=1 AND N=2
 
* '''-z'''N - Resets an online timer; N=2 resets total time, N=1, resets current time, and N=0 is the same as N=1 AND N=2
  
Line 37: Line 35:
  
 
{{mIRC|$ctimer}} can be used to return the name of the timer which triggered the current script while {{mIRC|$ltimer}} returns the name of the last timer which triggered.
 
{{mIRC|$ctimer}} can be used to return the name of the timer which triggered the current script while {{mIRC|$ltimer}} returns the name of the last timer which triggered.
 
== Quirks ==
 
 
You can check the {{mIRC|msl injection}} page to learn more about /timer's double evaluation issues.
 
 
/timer also has a special evaluation routine which checks for variable assignement (except /var), for example:
 
 
  //timer -ho 1 0 set -s %test 5 $(|) unset -s %test
 
 
Works correctly: /timer does not evaluate the variable %test both times as it recognize the assignement.
 
 
However this behavior is too intrusive, it is not possible to properly check for variable assigment:
 
 
  //var -s %a inc,%b somevalue | timer -ho 1 0 echo -s %a %b
 
 
here the variable %b's value disappear completely
 
  
 
== Example ==
 
== Example ==
If you want the command to work 1 time through 10 seconds, then:
 
 
<syntaxhighlight lang="mIRC">
 
//timer 1 10 echo -a This command worked with a delay of 10 seconds
 
</syntaxhighlight>
 
 
You can pass the name of an alias that should to work in 10 seconds:
 
 
<syntaxhighlight lang="mIRC">
 
//timer 1 10 test_timer
 
 
alias test_timer {
 
  echo -a This command worked with a delay of 10 seconds
 
}
 
</syntaxhighlight>
 
 
 
 
Below is a simple count down timer that uses a call-back alias once per second:
 
Below is a simple count down timer that uses a call-back alias once per second:
  
Line 109: Line 74:
 
   timer 0 1 echo -s $!time(hh:nn:ss)
 
   timer 0 1 echo -s $!time(hh:nn:ss)
 
}</syntaxhighlight>
 
}</syntaxhighlight>
 
Ending timers by using 'off' parameter, you can also end timers using wildcards.
 
 
<syntaxhighlight lang="mIRC">
 
alias test_timers {
 
  ; /test_timers
 
 
  ; creating 3 different names timers
 
  /timer[test_one] 1 3 echo -a Test one
 
  /timer[test_two] 1 6 echo -a Test two
 
  /timer[test_three] 1 10 echo -at Test three
 
 
  ; End only one of them
 
  /timer[test_one] off
 
 
  ; Ending all the timers created with 'test_' prefix
 
  /timer[test_*] off
 
}
 
</syntaxhighlight>
 
  
 
== Compatibility ==
 
== Compatibility ==

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)