mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2005
Posts: 14
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Mar 2005
Posts: 14
Hello there,

Is it possible to have multiple on TEXTs?

like for instans.
Code:
on ^*:TEXT:*:#:{
  if ( $1- isnum && $remove( $1- , 0 , 1 ) == $null ) {
    echo $chan BINARY $1-
    HALTDEF
  }
}

on ^*:TEXT:*:#:{
  echo $colour(normal) -t-m $chan 4 $+ < $+  $+ $nick $+ 4 $+ > $1-
  HALTDEF
}


Can this be made so that the first only changes the $1-, so that the second can change it again?

Thx.


GreetZ BlackDex
To boldly go where no one has gone before.
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You can only have one On Text event per mIRC script. The first one will cancel out any other occurrence in that mIRC script.

Joined: Mar 2005
Posts: 14
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Mar 2005
Posts: 14
So if i have 1 mIRC running..
And i have 2 scripts.. With both diffrent on text functions.
They both will work?


GreetZ BlackDex
To boldly go where no one has gone before.
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You can have as many On Text events as you want but one event per "Script.mrc". If you understand.

Script.mrc can have only one On Text event, the others will be canceled out.. smile

mIRC as awhole Idon't think there's an event limitation.

Last edited by SladeKraven; 31/03/05 04:01 PM.
Joined: Mar 2005
Posts: 14
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Mar 2005
Posts: 14
But if i understand it correct, i can't let one script pass it to the other right?

So for instains.
One on-text changes some words or something and then passes that to the second on-text that changes the colors etc..
And where both are independ of eachother?

What i mean is to change the $1- for example, and that the other on-text scripts just change that?


GreetZ BlackDex
To boldly go where no one has gone before.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
You can have as many ON ^*:TEXT: events as you like in one script file, BUT only one well be triggered, they well be compared for if they should be triggered from the top down, the first
one encountered that is ment to run well do so, and no others well be checked.

ON ^*:TEXT:*:* and ON *:TEXT:*:* are not considered the same event one is a preprocessor TEXT event one is a post process TEXT event so both would be triggered, the ^ one first.

You can have
on *:TEXT:*blah*:*:echo -s BLAH was said in $1-
on *:TEXT:*:*:echo -s BLAH was not said in $1-

Even thou the second one catches ALL text it well not catch text with "blah" in becuase it well be caught by the one above, and thus the bottom one never gets checked.

you can only have
on *:TEXT:*blah*:*:echo -s BLAH was said in $1-
and
on *:TEXT:*blah*:*:echo -s BLAH is a word in $1-
both work if they are in seperate files


As to your last question, NO you cant manipulate the $1- values and pass them to the next event handler, each event handler recieves the original $1-

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Sladekraven is incorrect when he says you can only have one on text event in an mIRC script file (wink@andy).

In fact you can have as many as you want in 1, but you need to organise them in a way, that each on text event only captures as much as it should.

Fex if you have 5 on text events, and the first one is one where the matchtext is *, this one will capture everything, thus making the other ones useless.

To show how you can use multiple, consider this test case.

on *:text:this is a test:*: { do things }
on *:text:this is a *:*: { do things }
on *:text:this is*:*: { do things }
on *:text:this*:*: { do things }
on *:text:*:*: { do things }

If someone says 'this is a test', the first one will trigger, and not the other ones. Had the order of on text events been different, for example the other way round, then it would have never triggered the right on text event. Instead the one with matchtext * would have captured it.

So far we only talked about differences in matchtext of the on text event. As you know, there is also a way to specify on what window the on text event should trigger.

We can choose out of:

? = for any private message
# = for any channel message
#mirc = for any messages on channel #mirc
* = for any private or channel messages

This also makes an important difference.

Consider the following 3 on text events:

on *:text:this*:#: { msg # triggered from a channel }
on *:text:this is a test:?: { msg $nick triggered from a query }
on *:text:*:*: { msg $iif($chan,$chan,$nick) triggered from either a channel or query }

So if I say 'this is a test' in a query, even though the first on text event matches on this*, it is not triggered, because it's for a channel. So the second on text gets triggered, because that is the one that reacts on a query window. (So does the third, but since the second is before the third, this one captures it instead.)

If I say 'this is" in the channel, the first one is triggered. The last one doesn't get triggered, even though it matches the text (*) and it is on a channel (* means channel or query in the location part of the event)

If i say "booo", in a pm or a channel, then the 3rd on text is triggered.


So far we discussed differences in matchtext and matchlocation in on text events. There is still something left to complicate things. As you may or may not know, we can use the ^ event prefix for certain events. This prefix is used so you can prevent the default text for an event from being shown, when used along with halt/haltdef.

Consider the following two on text events:

on *:text:*:#: msg # nr 1
on *:text:*:#: msg # nr 2

When you say anything in a channel, only the first will trigger and msg "nr 1". However, let's add a very small modification to the second on text event.

on *:text:*:#: msg # nr 1
on ^*:text:*:#: msg # nr 2

Now when you say something the script will message, in this order:

nr 2
nr 1

Putting a halt/haltdef after the second one, will prevent the text from being displayed, but will not prevent the first on text event there to trigger. If we would want that our first event does not trigger, after another event used a halt/haltdef, we need to modify it a bit. In particular, we need to prefix it with the & event prefix.

on &*:text:*:#: msg # nr 1
on ^*:text:*:#: msg # nr 2

Now what happens when we say something on the channel? It messages again first nr 2, then nr 1. When we add a halt/haltdef to the second on text event like this:

on &*:text:*:#: msg # nr 1
on ^*:text:*:#: msg # nr 2 | haltdef

The second on text event is now the only one triggered when something is said on a channel, whilst the first one is ignored. Btw, instead of using the & event prefix, one could also use the $halted identifier, which returns $true if a user has used /halt or /haltdef in a ^ event which was triggered prior to the current one, and $false if not.

on *:text:*:#:if !$halted { msg # nr 1 }
on ^*:text:*:#: msg # nr 2 | haltdef

The result is the exact same as the above with the & event prefix. The second on text with the ^ event prefix is triggered. Then the first on text event (without ^) is triggered, however, there is an if check to see if $halted is $true or $false (if !$halted means only proceed is $halted is $false). Since we did indeed use a haltdef or halt in the ^ event, the if condition fails, and stops processing. Therefore, it also only msges to the channel "nr 2".

Be very careful! Even though the result of using & and $halted were the same, they work inherently different. When you use the & event prefix, the event is never even triggered. In the case of $halted, the event is triggered but stops processing after the if condition that checks $halted, is $false. This can be an important difference in certain situations. For example:

Code:
on *:text:*:*:{
  echo -a triggered first event
  if !$halted { echo -a No halt/haltdef used in an on text event with ^ prior to this event }
}
on ^*:text:mirc:*: echo -a triggered second event | haltdef


If I say on a channel "mirc", then the second event with the ^ is triggered. Then the first event is also triggered and echo's "triggered first event"'. Then follows the if check for $halted, and since I did use a haltdef in the event with the ^, the if condition is false, thus the remote stops.
However if I say "this is a test", the first event is the only one triggered, and echo's 2 times since $halted is false now, thus making the if condition $true. The second event does not trigger because of the matchtext.


Phew, we're almost there. You didn't think that was it, did ya? There's more...

You can have multiple on text events in one remote file, even if they have the same matchtext, and without the use of ^,&, and halt/haltdef. It's with the use of #groups.

Consider the following example:

#group1 on
on *:text:*:?: msg $nick 1st group triggered | enable #group2 | disable #group1
#group1 end

#group2 off
on *:text:*:?: msg $nick 2nd group triggered | enable #group1 | disable #group2
#group2 end

The use of groups here like this can be handy in certain situations, as it can be scripted to act in a dynamic way.

Well, there might very well be still some things left to be said, but I'm writing this in the middle of working on my thesis, it wouldn't surprise me at all if I forgot some important parts here and there :tongue:

Btw just for clarification, to anyone that is trying the examples provided. You cannot trigger your own on text events. If you want to test on text events, it is best to have one client with the code (preferably a clean mIRC with no scripts installed as they may corrupt the results), and one mIRC to test. You could also use the multiserver ability of mIRC but for testing on text events, it is sometimes a bit too confusing.

Greets


Gone.
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Hehe yeah, I was talking in terms of:

Code:
on *:text:*:*: { do.things } 
on *:text:*:*: { do.more.things } 


In the same script which would of course trigger on the first event. But you are entirely right, it really depends on what you're trying to match. Both of the above would match but the second occurence canceled out.

Joined: Mar 2005
Posts: 14
B
Pikka bird
OP Offline
Pikka bird
B
Joined: Mar 2005
Posts: 14
Owkay... thx.. That clears it up for me smile.


GreetZ BlackDex
To boldly go where no one has gone before.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
Putting a halt/haltdef after the second one, will prefent the text from being displayed, but will not prevent the first on text event there to trigger. If we would want that our first event does not trigger, after another event used a halt/haltdef, we need to modify it a bit. In particular, we need to prefix it with the & event prefix.

on &*:text:*:#: msg # nr 1
on ^*:text:*:#: msg # nr 2

Now what happens when we say somethign on the channel? It messages again first nr 2, then nr 1. When we add a halt/haltdef to the second on text event like this:

on &*:text:*:#: msg # nr 1
on ^*:text:*:#: msg # nr 2 | haltdef

The second on text event is now the only one triggered when something is said on a channel, whilst the first one is ignored.


OMG I should really read the help file closer

I have a bunch of
ON ^*:TEXT:*:*{ if (!halted) { ....

/me goes and kicks a can around the yard while mumbling under my breath... grumble grumble events grumble grumble prefixs grumble grumble

* Very nice breakdown of events by the way.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe,

you have a good sense of humor Dave smile

Cya


Gone.

Link Copied to Clipboard