|
Gage Beginner
Joined: 07 Jan 2003 Posts: 23
|
Posted: Sun Mar 16, 2003 4:49 am
Match across new lines. |
How do you make a trigger match across lines?
Example:
You STUN %1
...WHO breaks the stun quickly off with intense concentration.
---------------------------
The first line You STUN %1 indicates a stun,
but the second line indicates a resist. I want to report the stuns, but not if they have resisted.
Thanks,
Gage
P.S.
Any reason why the search feature does not work (or is it just me)? |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Mar 16, 2003 11:50 am |
If the other line comes right after the first one, then you can catch it too, and then check to see that it is not the line that indicates a resist. Example:
#TRIGGER {You STUN (%w)$(*)} {#IF (!("%2" =~ "...WHO breaks the stun quickly off with intense concentration.")) {report stun}}
Kjata |
|
|
|
Gage Beginner
Joined: 07 Jan 2003 Posts: 23
|
Posted: Wed Mar 19, 2003 6:20 am |
Thanks for the example, I see some syntex I am unfamilar with... Please correct me if some of my assmuptions are wrong.
You STUN (%w)$(*)
%w matchs any word, and is stored in the %1 variable.
$ is end of line.
* is anything after the end of the line, it is stored in %2.
Question: Why are you including the %w and * inside ()'s?
#IF (!("%2" =~ "...WHO breaks the stun quickly off with intense concentration."))
Question: Why use the =~ ? Why not just = ?
Gage |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Mar 19, 2003 12:59 pm |
They are included in ()'s to tell zMUD to store whatever they match in the %1..%n variables. If they were not inside parenthesis, then they would still match the text, but whatever they match would not be accessible to you in the script of the trigger.
Theoretically, you could use the = operator in this case since the text %2 contains should either be that string completely or something else. However, I like to use the =~ operator because %2 contains a whole line and it may be possible that the line contains some indentation spaces at the beginning or that some other text may appear at the end. The comparison works with =~ and not with = because =~ is the pattern-matching operator. This operator matches the left operand agaisnt the pattern given as the right operand. What this means is that you can include wildcards such as * or %w in the text to the right of the =~, since it is a normal pattern just like any trigger would have.
Kjata |
|
|
|
|
|