mIRC Homepage
Posted By: Anti timer 0 $rand(x,y) - 22/08/20 02:31 AM
hello,

I'm looking for a loop timer that change time of timer every time with $rand identifier.
If I use :

timer 0 $rand(x,y) action ..

the timer loop go with the same value, for example if $rand(20,40) return 30 the command repeted will be :

timer 0 30 action

How may I set a different number for every loop of the timer ?

Thank you
Posted By: maroon Re: timer 0 $rand(x,y) - 22/08/20 02:47 AM
The delay is defined when the timer launches, so the only way to have the interval change each time - is to have the reps be 1, then set the delay again as the first action of the alias being called by that timer.
Posted By: Anti Re: timer 0 $rand(x,y) - 22/08/20 02:57 AM
Originally Posted by maroon
The delay is defined when the timer launches, so the only way to have the interval change each time - is to have the reps be 1, then set the delay again as the first action of the alias being called by that timer.



I thought this , but I should do something like:

while( I don't know what test ) {
timer 1 $rand(x,y)
}

What test may I use ?
Posted By: maroon Re: timer 0 $rand(x,y) - 22/08/20 03:07 AM
This alias will run itself at intervals ranging from 5 to 10 seconds each time you run it. It will stop that if you do "/dostuff off"

Code
alias dostuff {
  if ($1 == off) { timerdostuff off | return }
  timerDoStuff 1 $rand(5,10) dostuff
  here is where to put the things to do each time the timer triggers
 }
Posted By: Anti Re: timer 0 $rand(x,y) - 22/08/20 12:31 PM
Originally Posted by maroon
This alias will run itself at intervals ranging from 5 to 10 seconds each time you run it. It will stop that if you do "/dostuff off"

Code
alias dostuff {
  if ($1 == off) { timerdostuff off | return }
  timerDoStuff 1 $rand(5,10) dostuff
  here is where to put the things to do each time the timer triggers
 }


It's a strange code in programming, basically the trick is in the alias costruction, acts like a kind of "while" command or infinite loop as goto .
The core of the code is the costruction:

alias dostuff {
timerDoStuff 1 $rand(5,10) dostuff
commands
}

what does it mean to specify the alias name after the timer command? Moreover the commands must be put on a new line, otherwise it gives an error

This is really cryptic.

Thx
Posted By: maroon Re: timer 0 $rand(x,y) - 22/08/20 03:41 PM
It's not cryptic at all. The alias does stuff every <random> seconds. The first thing it does is set a timer so it will do something in the future. You can have the timer created as the last thing, if you want, as long as it gets created. If you want it to say 'hello' at a random interval between 15 to 20 minutes, which is 900 to 1200 seconds, you can have the alias be like:

alias dostuff {
msg #channelname hello #channelname
timerDoStuff 1 $rand(900,1200) dostuff
}
© mIRC Discussion Forums