mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
#108987 26/01/05 02:55 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Aww Dave, those eval brackets are evil.

var %a = $nick $+ $ticks

.timer.kill.addnews. $+ %a ...
...
set -u7 %news. $+ %a $2-

Good call on the escaping of that $2- string, it's something many people don't consider.


Gone.
#108988 26/01/05 03:29 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
yeah I know i dont need em on alot of them (actually i think it might have been all of them), and i considered not putting them in, but i just find, if i do it the same way everywhere (ie: have them) then it all works, better to have to many than to have to few I say, and yes they are evil!

I actually find this harder to read myself

Code:
on *:text:%getnews:#:{
  if ($istok(%friend,$nick,32)) {
    var %ticks = $ticks
    .timer.kill.getnews. $+ $nick $+ . $+ %ticks  1 5 .timer.getnews. $+ $nick $+ . $+ %ticks off
    ;
    ;
    .timer.getnews. $+ $nick $+ . $+ %ticks       1 6 play $nick NEWS.TXT 1000
    ;^ this plays the news.txt to the $nick in 6 seconds time
  }
}
on *:text:%addnews:#:{
  if ($istok(%friend,$nick,32)) {
    var %ticks = $ticks
    .timer.kill.addnews. $+ $nick $+ . $+ %ticks  1 5 .timer.addnews. $+ $nick $+ . $+ %ticks off
    ;
    ;
    set -u7 %news. $+ $nick $+ . $+ %ticks $2-
    .timer.addnews. $+ $nick $+ . $+ %ticks       1 6 write NEWS.TXT % $+ news. $+ $nick $+ . $+ %ticks
    ;^ this adds news to the NEWS.TXT file in 6 seconds
  }
}
on *:notice:STATUS & &:?:{
  if ((%friend.news) && ($nick == Nickserv) && ($istok(%friend,$2,32))) {
    if ($3 == 3) { .timer.kill.*. $+ $2 $+ . $+ * off } 
    else         { msg $2 %ID }
  }
}


Attn : Angrycat : try that or the other one before it, DONT use the one without the SET -u7 in the ON TEXT addnews either way.
And incase its hard to see what im doing im naming the timers such as...
Timer.addnews.Bobby.1660420408 & Timer.kill.addnews.Bobby.1660420408, the last number is $ticks (ticks since OS started), this within normal ircing well make it a unique timer name.
Thus the kill timers are unique and well kill there unique event timer, pretty crazy system but i felt it was a little simpler than having to spool & despool events, which can get harder if say three different nicks all went !addnews blah blah and then !news at the same time.

#108989 26/01/05 11:34 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
My point is not only the fact that the eval brackets are obsolete, but that you can put $nick $+ $ticks in a var, and shorten your code incredibly, and also increasing readability.

Though each has his own methods, so nvm smile

It's the difference between:

.timerbla $+ $nick $+ %ticks ..... timerbla $+ $nick $+ %ticks
set -u7 %something. $+ $nick $+ %ticks
.othertimer $+ $nick $+ %ticks

vs.

.timerbla $+ %a ..... timerbla $+ %a
set -u7 %something. $+ %a
.othertimer $+ %a

Greets


Gone.
#108990 26/01/05 03:14 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
My point is not only the fact that the eval brackets are obsolete, but that you can put $nick $+ $ticks in a var, and shorten your code incredibly, and also increasing readability.


Oh my I missunder stood that half of your message altogther, I thought you were just saying something about Telling me I didnt need the . (dots) between each section of the timer name and variable names, I thought "ok yeah I know i dont, but i like em since it lets you visually breakup the name if u list the timers or have -s on the sets. I totally understand now, your meaning jam all my repeating sections into a var and just refrence that, most correct, Im just lazy in I made the first timer, then i just pasted the code over and over for each one. Its much more efficient to modelize it into one occurance.

#108991 26/01/05 03:19 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
your meaning jam all my repeating sections into a var and just refrence that

Yep, that was what I meant. Cya!


Gone.
Page 2 of 2 1 2

Link Copied to Clipboard