|
|
Joined: Jan 2003
Posts: 11
Pikka bird
|
OP
Pikka bird
Joined: Jan 2003
Posts: 11 |
I have a quick question that I've been unable to figure out by looking at the FAQ, help file, and searching the forums (post by post no less!). I have a simple linkbot script that I run between channels. Whenever anyone uses the pipe character, it tries to execute a new command instead of just displaying it in the channel. Any help is much appreciated. Here's the simple code that I run. on *:TEXT:*:#ase:{
if ( $cid == 1 ) {
/scid 3 /msg #ase [G] < $+ $nick $+ > $1-
}
elseif ( $cid == 3 ) {
/scid 1 /msg #ase [Q] < $+ $nick $+ > $1-
}
}
-Ecks P.S. The multi-server capabilities in mIRC are amazing. That was the one thing that I thought was missing from it, and now it's damn near perfect.
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
You might try using $!1- .. or perhaps $!replace($!1-,|,$!chr(124)) .. one of those might do the trick.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
Joined: Dec 2002
Posts: 699
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 699 |
If you are always going to have those two connections as CID's 1 & 3 on *:TEXT:*:#ase:{
var %a = $($1-,1),%b = $gettok([G]: :[Q],$cid,58),%c = 4 - $cid
scid %c if ($me ison #ase) msg #ase %b $+(<,$nick,>) % $+ a
}
|
|
|
|
Joined: Jan 2003
Posts: 11
Pikka bird
|
OP
Pikka bird
Joined: Jan 2003
Posts: 11 |
Yes, the connections remain the same. I'm only designing this script for me (although maybe I'll rewrite it so anyone can use it later). Your code worked wonderfully Nimue: but I was wondering if you'd explain the $($1-,1) section to me. I don't understand what this does (and it's obviously how you solved my problem since the rest is virtually the same as my code). Also, why did you re-write everything? Are variables quicker than if statements? Thanks for your help, it's much appreciated.
-Ecks
|
|
|
|
Joined: Dec 2002
Posts: 699
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 699 |
Oops yes I am used to using it for myself and sometimes forget to NOT use it elsewhere. $($1-,1) is simply a "shortcut" to $eval($1-,1) I used this way simply for economy of code, you could do the same with "if (this) / elseif (that)"
|
|
|
|
Joined: Jan 2003
Posts: 11
Pikka bird
|
OP
Pikka bird
Joined: Jan 2003
Posts: 11 |
Thanks again. I like to know how stuff works just as much as knowing that it DOES work. It kind of confused me that your version works when if you replace the $1- in my code with the $eval($1-,1) in your code it doesn't work. Is it that when you place it into a variable, it doesn't try to evaluate it at all? That's the only thing I can think of. Kind of a hack, but I'm glad it works . -Ecks
|
|
|
|
Joined: Dec 2002
Posts: 699
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 699 |
This is because identifiers are evaluated for each command that processes them. So, once when you send them to a different CID (/scid N), and then again when a command (in this case "/msg") is used. Setting it unevaluated to %var and then using "/scid N /command % $+ var" inserts an extra evaluation (the $+), which you obviously cant do with "$!1-" / "$ $+ 1-" or it will evaluate literally to "$1-" Hope that helps.
|
|
|
|
Joined: Jan 2003
Posts: 11
Pikka bird
|
OP
Pikka bird
Joined: Jan 2003
Posts: 11 |
Yes, indeed it does. Thanks for the thorough explanation.
-Ecks
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
There is a much simpler solution to your problem than of trying to avoid evaluations. Just "switch" the script to the proper CID and then execute any commands you want.
on *:TEXT:*:#ase:{
if $cid == 1 || $cid == 3 {
scid $mid(301,$cid,1)
msg #ase $+(<,$nick,>) $1-
}
}
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
|
|