mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2007
Posts: 40
S
silimon Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2007
Posts: 40
I want to use the on TEXT event in a way where it only triggers if certain words were typed. Ideally, I'd like it to allow a wild card so long as one of the words on the list is in the text.

I *can* have it trigger on all text and parse through it myself, but I'd rather not have the event trigger all the time.

Is this possible?

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: silimon
I want to use the on TEXT event in a way where it only triggers if certain words were typed. Ideally, I'd like it to allow a wild card so long as one of the words on the list is in the text.
You can use regex in a text event like this:
Code:
on $*:TEXT:/(word1|word2|word3|word4|word5)/iS:#: {
Quote:
I *can* have it trigger on all text and parse through it myself, but I'd rather not have the event trigger all the time.Is this possible?
I'm not sure what you mean by that.

Joined: Mar 2007
Posts: 40
S
silimon Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2007
Posts: 40
I'll give that a shot.

Quote:
Quote:
I *can* have it trigger on all text and parse through it myself, but I'd rather not have the event trigger all the time.Is this possible?
I'm not sure what you mean by that.


I meant have the event trigger on * (any text) and parse through it with a series of if statements to find what I'm looking for. However, that means everytime someone said something in chosen channel, the event would trigger.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The best you can do, if I understand correctly, is to have the event triggered each time, and have the conditions checked, and if none of the conditions fit, then do nothing.

With the speed of most computers these days, you'd probably need a 250+ line code before anyone might notice that a script was/was not responding.

Basic code:
Code:
on *:text:*:#:{
  if ($1- == first condition) {
    ;response for first condition
  }
  elseif ($1- == second condition) {
    ;response for second condition
  }
  elseif ($1- == third condition) {
    ;response for third condition
  }
  elseif ($1- == fourth condition) {
    ;response for fourth condition
  }
  elseif ($1- == fifth condition) {
    ;response for fifth condition
  }
}


I only did 5 sample conditions, but there's (realistically) no limit as to the number of conditions you can have.



Link Copied to Clipboard