mIRC Homepage
Posted By: vexed2 timers - 27/04/08 04:35 PM
I've decided to script /timers to match in with my theme, but i got a question about one of the properties.
I've made a loop to list them all, but i'm using $timer(%i).delay to show the delay of course, but is there a suffix to add to it so it can show if it's a 1 second timer, a 100ms timer, a 1hour timer etc etc.
Thanks in advance.
Posted By: RoCk Re: timers - 27/04/08 04:51 PM

I never realized there was no property to return $true/$false for the -m switch. There should be a .ms property for the $timer() identifier. You should suggest it. smile
Posted By: vexed2 Re: timers - 27/04/08 04:55 PM
Ahh, there's me scouting through the help file to find anything i may have missed, i thought i may have got a reply that said 'have youlooked in the help file' lol whistle

I shall do that!
Posted By: qwerty Re: timers - 27/04/08 05:42 PM
This should do the trick:
Code:
alias isms if ($timer($1).delay) return $iif($calc($timer($1).secs * 1000) <= $v1,$true,$false)
$isms(blah) returns $true if 'blah' is a millisecond timer.
Posted By: vexed2 Re: timers - 27/04/08 06:07 PM
I ran a 500ms timer as a check

* Timer 1 500ms delay time::setup (Stonedpenguin)

$isms(1) returns $false for me
Posted By: RoCk Re: timers - 27/04/08 06:17 PM

It returned $true every time for me when I tried a 500ms timer, named and numbered.
Posted By: vexed2 Re: timers - 27/04/08 06:17 PM
hmm, odd.
If it's named it returns $true, if it's a number it always returns $false crazy

It seems it's not consistant, if i use it in my /timers alias the results keep changing everytime i do /timers
My timers that are in seconds sometimes return $false and $true
same with the millisecond ones
Posted By: qwerty Re: timers - 27/04/08 06:21 PM
This is not a problem with the alias but with the fact that unnamed (or numerically named) timers are kind of tricky to work with: $timer() accepts either a name or a number, but when a number is specified, it is always treated as an index, not as a timer name. To see this point, try:

//.timertest 1 0 noop | .timer1 1 0 noop | echo -a $timer(1)

So, assuming you can find the right timer instance, $isms should work correctly. Example:

//.timertest -m 6 500 noop | echo -a $isms(test) | .timer 1 2 echo -a $!isms(test)

should output $true twice.
Posted By: RoCk Re: timers - 27/04/08 06:25 PM

/timerTEST -m 0 500 echo -a test1
-
* Timer test activated
-

/timer 0 1 echo -a test2
-
* Timer 1 activated
-

//echo -a $isms(1) <--
$false <--

~ Edit ~
What he said.


Posted By: RoCk Re: timers - 27/04/08 06:31 PM

Originally Posted By: qwerty

but when a number is specified, it is always treated as an index, not as a timer name.



Well it seems that's not always true if you look at my last post, if it were then it should have returned $true, but in my example, the 2nd timer is named 1 and is not a ms timer and your identifier returned $false. If the number 1 were treated as an index in my case, then it should have returned $true becuse the first timer IS a ms timer.
Posted By: vexed2 Re: timers - 27/04/08 06:35 PM
I have 2 timers running at 500ms, 1 named, 1 not.
The results keep changing
They both sometimes return $true and both sometimes return $false AND 1 shows to be $false while the other $true.
No consistancy crazy
Posted By: RoCk Re: timers - 27/04/08 06:41 PM

Try using the -d switch when you start the timers and see if there's a difference in consistancy.
Posted By: vexed2 Re: timers - 27/04/08 06:45 PM
I don't mean for the actual timers, i'm saying i have two 500ms timers running, 1 named and 1 not.
When doing /timers using qwerty's alias they keep changing between $false and $true

       [#4 ] [500 ] [online ] [$false ] [1 ] [time::setup ]
       [#5 ] [500 ] [online ] [$true ] [test ] [time::setup ]

Both 500ms, so why is one false? lol
Posted By: RoCk Re: timers - 27/04/08 06:51 PM

Are those the only two timers running? Maybe it's returning $false for another timer that's not a ms timer.
Posted By: vexed2 Re: timers - 27/04/08 06:55 PM
You're right, it is.

       [#1 ] [500 ] [online ] [$true ] [1 ] [time::setup ]
       [#2 ] [500 ] [online ] [$true ] [test ] [time::setup ]

       [#1 ] [1 ] [online ] [$false ] [_sbar ] [sbar::update ]
       [#2 ] [500 ] [online ] [$false ] [1 ] [time::setup ]
       [#3 ] [500 ] [online ] [$true ] [test ] [time::setup ]
Posted By: qwerty Re: timers - 27/04/08 07:15 PM
Originally Posted By: RoCk

Originally Posted By: qwerty

but when a number is specified, it is always treated as an index, not as a timer name.



Well it seems that's not always true if you look at my last post, if it were then it should have returned $true, but in my example, the 2nd timer is named 1 and is not a ms timer and your identifier returned $false. If the number 1 were treated as an index in my case, then it should have returned $true becuse the first timer IS a ms timer.
This is happening because it seems mirc doesn't order timers according to their creation time (from the scripter's point of view). I'm not sure how it does it exactly but one this is for sure: that order changes as timers fire (maybe timers with reps > 1 are treated as separate 1-rep timers, in the sense that they are re-inserted in mirc's timer list each time).

Try this for example:

//.timertest -m 0 500 noop | .timer 0 1 noop | .timerecho -m 0 100 echo -a $!timer(1)

Small excerpt of the results here:
Quote:
1
1
1
echo
1
1
1
1
1
1
1
1
test
1
1
1
Posted By: RoCk Re: timers - 27/04/08 07:18 PM

Yeah that's what I was thinking too. Instead of a timer started with 0 reps being one continuous timer executing every N seconds, it actually restarts everytime it executes?
© mIRC Discussion Forums