mIRC Home    About    Download    Register    News    Help

Print Thread
#267616 22/08/20 02:31 AM
Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26
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

Anti #267617 22/08/20 02:47 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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.

Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26
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 ?

Anti #267619 22/08/20 03:07 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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
 }

Joined: Mar 2015
Posts: 26
A
Anti Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Mar 2015
Posts: 26
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

Last edited by Anti; 22/08/20 01:14 PM.
Anti #267623 22/08/20 03:41 PM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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
}


Link Copied to Clipboard