mIRC Home    About    Download    Register    News    Help

Print Thread
#198378 27/04/08 04:35 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
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.

vexed2 #198379 27/04/08 04:51 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

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

RoCk #198380 27/04/08 04:55 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
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!

vexed2 #198381 27/04/08 05:42 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
qwerty #198383 27/04/08 06:07 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
I ran a 500ms timer as a check

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

$isms(1) returns $false for me

vexed2 #198384 27/04/08 06:17 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

It returned $true every time for me when I tried a 500ms timer, named and numbered.

RoCk #198385 27/04/08 06:17 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
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

Last edited by vexed2; 27/04/08 06:25 PM.
vexed2 #198386 27/04/08 06:21 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
vexed2 #198387 27/04/08 06:25 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

/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.



qwerty #198388 27/04/08 06:31 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

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.

RoCk #198389 27/04/08 06:35 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
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

vexed2 #198391 27/04/08 06:41 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Try using the -d switch when you start the timers and see if there's a difference in consistancy.

RoCk #198392 27/04/08 06:45 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
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

vexed2 #198393 27/04/08 06:51 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Are those the only two timers running? Maybe it's returning $false for another timer that's not a ms timer.

RoCk #198394 27/04/08 06:55 PM
Joined: Mar 2007
Posts: 218
V
vexed2 Offline OP
Fjord artisan
OP Offline
Fjord artisan
V
Joined: Mar 2007
Posts: 218
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 ]

RoCk #198397 27/04/08 07:15 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
qwerty #198398 27/04/08 07:18 PM
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

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?


Link Copied to Clipboard