mIRC Homepage

Decreasing %var by 10 every second

Posted By: Jonkka

Decreasing %var by 10 every second - 25/05/05 02:43 PM

when I try to this with /dec I it only decreases %var with 10 the first time, after that it just decreases it with 1 per second. I want it to decrease it with 10 per second, or actually 1 per 0.10 second, how can i do this?
Posted By: mIRCManiac

Re: Decreasing %var by 10 every second - 25/05/05 02:56 PM

Yeah I would think that if a value is supplied when the -c -z
switches are used, it should increase/decrease by that value
every second. I don't know if this is something for bug reports
or feature suggestions.
confused
Posted By: droi

Re: Decreasing %var by 10 every second - 25/05/05 06:22 PM

You could use:

/timer 0 1 /dec %var 10
Posted By: SladeKraven

Re: Decreasing %var by 10 every second - 25/05/05 07:49 PM

With that the var wont unset, and plus it decreases by 10 each time. They wanted to decrease by 10 the first time, then decrease every second.

//set %var 50 | dec %var 10 | dec -z %var

Set the variable %var with a value of 50, takes 10 from it with "dec %var 10" then decreases every second with the -z switch.

-Andy
Posted By: RusselB

Re: Decreasing %var by 10 every second - 25/05/05 10:51 PM

This'll decrease the value in %var by 1 every 1/10th of a second (or 100 milliseconds) but only if %var has a value greater than 0
Code:
/timer -m 0 100 { if (%var > 0) { .dec %var } } 
Posted By: DaveC

Re: Decreasing %var by 10 every second - 26/05/05 07:09 AM

Code:
;Multimedia speed -z options for /SET
;
;usage: /SET -mNNNN,VVVV %var value
;  -m (lower case ONLY, using uppercase well have undefined results)
;  NNNN is number of milliseconds before next subtraction occurs (invalid values well default to 1000)
;  VVVV is value to subtract (negitive values well be considered positive, invalid values (including zero) well default to 1)
;
;   Example   /SET -m100,2.5 %var 99.81    ( %var is set to 99.81 then every 10th of a second 2.5 is subtracted, untell the value falls below zero and the %var is unset )
;   Example   /SET -m1500,-1.4 %var 12.5x  ( %var is set to 12.5x then every 1.5 seconds 1.4 is subtracted, first subtracted result well make %var 11.1 )
;   Example   /SET -m2000,3 %var x12.5     ( %var is set to x12.5 then in 2 seconds 3 is subtracted, first subtraction results in -3 and %var is unset )
;   Example   /SET -sm200,.001z %var 10    ( %var is set to 10 then every 5th of a seconds 0.001 is subtracted, when the second changes 1 is subtracted due to the -z option )
;                                          ( NB: the -z option goes off as the second changes, not in 1 second from its inital setting, so there may or maynot be 5 -m200 events before it)
;
; NB: the -s & -n & -z options are functional.
; The -u option well function ONLY if the unset occurs BEFORE the first NNNN milliseconds, this essentially means it is disabled.
; This was becuase I was unable to locate a function or property ( similar to $hget(name/N, item).unset ) that could supply me the remaining time before an unset occurs.
;
#set_-m on
alias set {
  if ((-*m* iswmcs $1) && ($3)) {
    var %rate = $iif(($int($calc($mid($1,$calc($pos($1,m,1) + 1)) * 1)) isnum 1-),$v1,1000)
    var %size = $iif(($abs($calc($mid($1,$calc($pos($1,$chr(44),1) + 1)) * 1)) > 0),$v1,1)
    $+( .timer.set_-m.,$2 -mo 0 %rate $iif(!$show,.) $+ set $replacexcs($1,m,M) $2 %size )
    $iif($isalias(set.dispatcher),set.dispatcher) $+( $iif(!$show,.) , set $1- )
  }
  elseif ((-*M* iswmcs $1) && ($2)) {
    if ($calc($calc($eval($2,2) * 1) - $3) > 0) {
      $iif($isalias(set.dispatcher),set.dispatcher) $+( $iif(!$show,.) , set $1 $2 [ $v1 ] )
    }
    else {
      .timer.set_-m. $+ $2 off
      $+( $iif(!$show,.) , unset $iif(($1 == -Ms),-s) $2 $3- )
    }
  }
  else {
    .timer.set_-m. $+ $iif((-* !iswm $1),$1,$2) off
    $iif($isalias(set.dispatcher),set.dispatcher) $+( $iif(!$show,.) , set $1- )
  }
}
;
; ** If you do not beleieve you well ever have another /SET alias installed then the remove the set.dispatcher alias
;
alias -l set.dispatcher {
  .timer 1 0 .enable #set_-m
  .disable #set_-m
  $1-
  .enable #set_-m
}  
#set_-m end



** below is for anyone whoes interested.....

* the set.dispatcher alias is becuase i have another /SET alias, and i wanted them to both run, so i had to get this one to dispatch out the command to the other one.

* things i learnt while writting this....

1) watch where ya use $v1 if your using $iif() in front of it, see the [ $v1 ] to force its value in before it was changed frown * that was a hard bug to find!

2) $show doesnt work quite right all the time, this line
$+( .timer.set_-m.,$2 -mo 0 %rate $iif(!$show,.) $+ set $replacexcs($1,m,M) $2 %size ) was originally written as
.timer.set_-m. $+ $2 -mo 0 %rate $+( $iif(!$show,.) , set $replacexcs($1,m,M) $2 %size ) ) however the $show was returning the state based on the .timer not the alias as it was called, ( $show was processed during the timer creation not during its execution )
© 2022 mIRC Discussion Forums