mIRC Home    About    Download    Register    News    Help

Print Thread
#107126 07/01/05 07:31 AM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
Code:
on *:text:*:?:{
  if ( $nick == IdleRPG ) {
    tokenize 59 $1-
    set %idlerpg_1 $1
    set %idlerpg_2 $2
    set %idlerpg_3 $3
    set %idlerpg_4 $4
    set %idlerpg_5 $5
    echo -t 4STATUS reply @ #Idle-RPG:
    echo -t -> %idlerpg_1
    echo -t -> %idlerpg_2
    echo -t -> %idlerpg_3
    echo -t -> %idlerpg_4
    echo -t -> %idlerpg_5
    close -m $nick
  }
  else { echo -t 4PM from $nick -> $1- | close -m $nick }
}


This is ugly code, but I don't know how to clean it up. Any ideas? Thanks!

#107127 07/01/05 08:34 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Code:
on *:text:*:?:{
  if ( $nick == IdleRPG ) {
    tokenize 59 $1-
   echo -t 4STATUS reply @ #Idle-RPG:
    echo -t -> $1
    echo -t -> $2
    echo -t -> $3
    echo -t -> $4
    echo -t -> $5
    close -m $nick
  }
  else { echo -t 4PM from $nick -> $1- | close -m $nick }
}


or maybe even

Code:
on *:text:*:?:{
  if ( $nick == IdleRPG ) {
    tokenize 59 $1-
   echo -t 4STATUS reply @ #Idle-RPG:
    var %x = 1
    while (%x <= 5) { echo -t -> $eval($+($,%x),2) | inc %x }
    close -m $nick
  }
  else { echo -t 4PM from $nick -> $1- | close -m $nick }
}


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#107128 07/01/05 03:34 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
its simplified too much now smile
the vars need to be set too, they are used by other parts of the script.
i'll try to fix that the same way as you fixed the rest

EDIT: why is the $eval() used? why id yhis checked for something 2 times? I son't really understand the help file about this function :s

Last edited by LethPhaos; 07/01/05 03:36 PM.
#107129 07/01/05 05:56 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Although the code might look a little dodgy, rest assure it works, and you shouldn't change anything in the scon part, and the tokenize part. Why am I tokenizing on $1- $1-? Well because there is a bug with the counter of $* not being reset after using it. Anyway, this'll work, and quite fast might I add.

Code:
on *:text:*:?:{
  if $nick == IdleRPG {
    tokenize 59 $1-
    var %a 
    scon -r inc % $+ a $(|,) set % $+ idlerpg_ $!+ % $+ a $*
    echo -t 4STATUS reply @ #Idle-RPG:
    tokenize 32 $1- $1-
    echo -t -> $*
  }
  else echo -t 4PM from $nick -> $1- 
  close -m $nick
}


But anyway, if you want a more common approach go with the thing LocutusofBorg gave you, it's more than fine. I added the part so it sets variables too.
Code:
on *:text:*:?:{
  if $nick == IdleRPG {
    tokenize 59 $1-
    echo -t 4STATUS reply @ #Idle-RPG:
    echo -t $*
    var %x = 1
    while %x <= 5 { 
      set %idlerpg_ $+ %x $($+($,%x),2)
      inc %x 
    }
  }
  else { echo -t 4PM from $nick -> $1- }
  close -m $nick
}


Greets


Gone.
#107130 07/01/05 06:12 PM
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Nice idea, you could even simplify it further by including the /set command within the /scon:

Code:
    tokenize 59 $1-
    var %a
    echo -t 4STATUS reply @ #Idle-RPG:
    scon -r inc $(%a |,) set $(%idlerpg_ $+ %a,) $* $(|) echo -t -> $*


Guess you also need to be sure that the bot will never message anything that would exploit /scon's re-evaluating behavior

#107131 07/01/05 06:27 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Yep, good thinking.

I prefer the way you use $eval too, think I'm gonna use it more often rather than $+, saves some bytes too.

For Lethpaos:

What was once your big code is now reduced to:

Code:
on *:text:*:?:{
  if $nick == IdleRPG {
    tokenize 59 $1-
    var %a
    echo -t 4STATUS reply @ #Idle-RPG:
    scon -r inc $(%a |,) set $(%idlerpg_ $+ %a,) $* $(|) echo -t -> $*
  }
  else echo -t 4PM from $nick -> $1- 
  close -m $nick
}


Greets

Last edited by FiberOPtics; 07/01/05 06:30 PM.

Link Copied to Clipboard