mIRC Home    About    Download    Register    News    Help

Print Thread
$calc(%i -1) #213097 17/06/09 09:23 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Hello,

Any help with this i want to make it to count 10,9,8,7,6,5,4,3,2,1,0 and not 1,2,3....

Code:
alias -l count {
  var %x = 60
  var %i = 1
  while (%i <= %x) {
    .timer[count_ $+ %i $+ ] 1 %i did -ra list 5 Scan again in ( $+ %i $+ )
    .timer[count_ $+ %x $+ ] 1 %x did -ra list 5 Scan again
    .timer[count_ $+ $calc(%x -1) $+ ] 1 $calc(%x -1) did -e list 5
    dec %i
  }
  dec %i
}

i try this but nothing ..

Re: $calc(%i -1) [Re: westor] #213101 18/06/09 01:23 AM
Joined: Jul 2006
Posts: 3,585
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,585
If you want it to go from 60 to 0, you have to say "while %x > 0 then dec %x", assuming %x is set to 60 first


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $calc(%i -1) [Re: westor] #213102 18/06/09 02:17 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You're decreasing %i when %i is the lower bound value.. the loop will never terminate. If you name your variables less cryptically this mistake should become evident.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: $calc(%i -1) [Re: Wims] #213104 18/06/09 07:29 AM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Originally Posted By: Wims
If you want it to go from 60 to 0, you have to say "while %x > 0 then dec %x", assuming %x is set to 60 first


You mean this? i try it and didn't get result

Code:
alias count {
  var %x = 60
  while (%x > 0) {
    .timer[count_ $+ %x $+ ] 1 %x echo -s Scan again in ( $+ %x $+ )
    .timer[count_ $+ %x $+ ] 1 %x echo -s Scan again
    .timer[count_ $+ %x $+ ] 1 %x echo -s Scan again (enable id)
    dec %x
  }
  dec %x
}

Last edited by westor; 18/06/09 07:30 AM.
Re: $calc(%i -1) [Re: westor] #213107 18/06/09 09:18 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
1) the delay on your timers are going to start at the high end, and work their way down.
Thus the first timer you set won't execute until 60 seconds after it is set.
Additionally, while using named timers is a good idea, you're setting the same timer 3 times. Look at your naming configuration.
2) Your entire loop will probably process before the last timer executes (this would have a delay of 1 second).
3) You have an extra dec %x in the code.

See if this meets your requirements.
Code:
alias count {
  var %x = 60
  while %x {
    $+(.timer,[count_,%x,]) 1 1 scan %x
    dec -cze %x
  }
}
alias -l scan {
  echo -s Scan again in ( $+ $1 $+ )
  echo -s Scan again
  echo -s Scan again (enable id)
}


Re: $calc(%i -1) [Re: westor] #213111 18/06/09 03:02 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Instead of starting a ton of timers, you can use a single timer and the .reps property of $timer
Code:
; /count <N>

alias count {
  echo -s Countdown: $$1 
  .timerCount $1 1 $!iif(($timer($ctimer).reps > 0), ECHO -s Countdown: $!v1, ECHO -s <some command>)
}