Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Multiline trigger matching both multiline, and single line..
Multiline trigger matching both multiline, and single line..
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Trevize
(21 posts) Bio
|
Date
| Sat 16 Jan 2010 02:26 PM (UTC) Amended on Sat 16 Jan 2010 02:28 PM (UTC) by Trevize
|
Message
| Alright, I'm tired of browsing the forum for an answer to this question. Just feel impossible to find anything ever :/
Back the topic..
Zenigra stands an Aeon tarot on his open palm, and blows it lightly at Enteri.
Juganothion stands an Aeon tarot on his open palm, and blows it lightly at
Juganothion.
I want to match these two. The single line is easy to match, just do a simple: "^w+ stands an Aeon tarot on (his|her) open palm\, and blows it lightly at \w+\.$"
The multiline however is where I'm having problems, since I dont know exactly where the line break will show up this is what I'm using: "^\w+ stands an Aeon tarot on (his|her) open palm\, and blows it\s{1,2}lightly\s{1,2}at\s{1,2}\w+\.$"
This triggers perfectly, but for some freaking reason it triggers the single line too.. So it calls the function I want to call, but twice. (To clarify, the multiline trigger is called twice by the single line, even though I've specified it to match two lines)
<triggers>
<trigger
enabled="y"
lines_to_match="2"
match="^(\w+) stands an Aeon tarot on (his|her) open palm\, and blows it\s{1,2}lightly\s{1,2}at\s{1,2}(\w+)\.$"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>Note("called")</send>
</trigger>
</triggers>
I've tried with and without evaluate.
And since the multiline trigger, triggers both the single line and the multiline it would be awesome if I could just get it to be called once. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #1 on Sat 16 Jan 2010 07:57 PM (UTC) Amended on Sat 16 Jan 2010 08:02 PM (UTC) by Twisol
|
Message
| Personally, multi-line triggers are more trouble than they're worth; in IRE games (as you appear to be playing) you tend to use them mostly because of your server-side screenwidth configuration. By default I think it's usually 80, so all lines that are more than 80 characters are broken into multiple lines and then sent. This causes problems with triggers, clearly.
The solution is usually to configure your screenwidth to 0, disabling server-side wrapping altogether, and then configure MUSHclient to do it for you (in Game -> Configure -> Ouput); it shouldn't be hard at all to get it to look exactly the same. Then you'd only need a single-line match for both triggers.
For the reason why the second one is triggering on the first one too, umm... if you look at what you're doing, it's just a more general form of the first one. Hence, it will match anything the first one will match. \s{1,2} will match one or two whitespace characters. That's exactly what a single space does in the first one, except more specifically a space character and only one of it.
EDIT: Lastly, your multi-line trigger isn't really a multi-line trigger. There are no extra newline match symbols (i.e. $) in there. I must admit I'm rather befuddled here. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sat 16 Jan 2010 11:52 PM (UTC) |
Message
|
Twisol said:
EDIT: Lastly, your multi-line trigger isn't really a multi-line trigger. There are no extra newline match symbols (i.e. $) in there. I must admit I'm rather befuddled here.
The \s matches space characters including newlines.
Trevize said:
This triggers perfectly, but for some freaking reason it triggers the single line too ...
Instead of ending with a $ you need to end with \Z which says "end of subject". This means the text has to be at the "tail" of the two lines, not somewhere in the middle. This worked for me on your test data:
<triggers>
<trigger
enabled="y"
lines_to_match="2"
match="^(\w+) stands an Aeon tarot on (his|her) open palm, and blows it\s+lightly\s+at\s+(\w+)\.\Z"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>Note("called")
Note "%%1 = %1"
Note "%%2 = %2"
Note "%%3 = %3"
</send>
</trigger>
</triggers>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
BTW I think that \s+ is simpler for "one or more spaces" than \s{1,2} (admittedly you are allowing for only one or two, but why be that specific?)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 16 Jan 2010 11:52 PM (UTC) |
Message
| Having said that I agree with Twisol that if you can configure the MUD to not artifically wrap, you solve all these problems anyway. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #4 on Sun 17 Jan 2010 12:12 AM (UTC) |
Message
|
Nick Gammon said:
Twisol said:
EDIT: Lastly, your multi-line trigger isn't really a multi-line trigger. There are no extra newline match symbols (i.e. $) in there. I must admit I'm rather befuddled here.
The \s matches space characters including newlines.
Ah, I didn't realize that. Thanks. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Azeral777
(6 posts) Bio
|
Date
| Reply #5 on Mon 18 Jan 2010 02:51 PM (UTC) Amended on Mon 18 Jan 2010 02:52 PM (UTC) by Azeral777
|
Message
|
Twisol said:
The solution is usually to configure your screenwidth to 0, disabling server-side wrapping altogether, and then configure MUSHclient to do it for you (in Game -> Configure -> Ouput); it shouldn't be hard at all to get it to look exactly the same. Then you'd only need a single-line match for both triggers.
I cannot thank you enough for this advice, I just spent perhaps an hour struggling to highlight or trigger off of something so simple as '* shadow of a crow *' without knowing where it might be interrupted by newlines (or, in a few longer examples, if something might be divided into two or three lines at any given time).
Setting server-side wrapping to 0 has made IRE trigger-making infinitely more tolerable. | Top |
|
Posted by
| Trevize
(21 posts) Bio
|
Date
| Reply #6 on Mon 18 Jan 2010 04:10 PM (UTC) |
Message
| Thanks alot all, and what Nick posted solved my problem.
I still dont get what the diffrence is between $ and \Z
$ <- is End of line? is'nt that the End of the line ^^
\Z <- end of subject you say, or the tail of the two lines, is'nt that the same thing as $ which will be at the tail/end of the line?
And Twisol, sadly it's not the client that cuts the lines after 80 characthers, it's the IRE mud i'm playing -_- | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #7 on Mon 18 Jan 2010 04:32 PM (UTC) |
Message
| I haven't used \Z much, but I think I know and am able to explain the difference.
The difference only matters for multi-line triggers. Why? See two paragraphs down for the answer.
First, $ on its own matches nothing. It is merely a positional conditional, that is satisfied when the next position matches the end of the input _or_ a new line. Or in other words, it does not consume. So, a regular expression for yawns.$$$$$$ has exactly the same functionality as yawns.$. ^ is the same way, except for the beginning side of the line and string.
\A and \Z are far more specific. They only match respectively the beginning and end of the _whole_ input string. It is still a conditional, and they still do not consume.
Triggers are usually firing on single lines. Thus, \A and ^m, as well as \Z and $ are functionally the same in that scenario. With multi-line triggers, the difference begins to matter.
I usually do not bother with \A and \Z however, for the simple reason that I know the games I play don't allow other newlines to be inserted in my output other than the ones the game wants to have there, so only having ^ and $ simply keeps my triggers easier to understand. So usually, my few rare multi-line triggers look like ^Line one\.\nLine two\.$
Also, Trevize... try a command like CONFIG WRAPWIDTH 0. That's the one to disable wrapping on Aetolia at least, I don't know about other games. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #8 on Mon 18 Jan 2010 05:18 PM (UTC) |
Message
|
Trevize said:
And Twisol, sadly it's not the client that cuts the lines after 80 characthers, it's the IRE mud i'm playing -_-
No, that's what I mean - try CONFIG WRAPWIDTH 0, like Worstje said, or CONFIG SCREENWIDTH 0 (for Achaea at least). Then you can have MUSHclient do the wrapping for you instead of the MUD. The end result should be that everything looks the same, but it's wrapped client-side instead of server-side. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #9 on Mon 18 Jan 2010 08:48 PM (UTC) |
Message
|
Trevize said:
I still dont get what the diffrence is between $ and \ZZ
$ <- is End of line? is'nt that the End of the line ^^
I agree with Worstje here.
$ is "end of line", yes. And in a 2-line multiline trigger you will have 2 ends of lines.
However \Z is "end of subject". In a 2-line multiline trigger there is only one end of subject.
Take for example:
Incoming text:
It rains.
You see fish <--- match end of line
Now another line appears:
You see fish <--- match end of line
Nick says 'hello'
It matches a second time.
Now try again with \Z:
Incoming text:
It rains.
You see fish <--- match end of subject
Now another line appears:
You see fish
Nick says 'hello'
Now it only matches once.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Kevnuke
USA (145 posts) Bio
|
Date
| Reply #10 on Tue 23 Feb 2010 08:18 AM (UTC) |
Message
| I also didn't know that \s matched newlines, thanks! But the problem with changing the server-side screenwidth to zero, is that some plugins require the default 80 screenwidth to function properly (some of Trevize's specifically). And to attempt to simplify.. $ matches the end of -any- line, while \Z matches the end of the -last- line of a multiline trigger, or if you want, you can use \Z instead of $ on single line triggers.. But it'd just be more typing. And yes, the MUD in question is Achaea. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #11 on Tue 23 Feb 2010 09:05 AM (UTC) |
Message
|
Kevnuke said:
I also didn't know that \s matched newlines, thanks! But the problem with changing the server-side screenwidth to zero, is that some plugins require the default 80 screenwidth to function properly (some of Trevize's specifically). And to attempt to simplify.. $ matches the end of -any- line, while \Z matches the end of the -last- line of a multiline trigger, or if you want, you can use \Z instead of $ on single line triggers.. But it'd just be more typing. And yes, the MUD in question is Achaea.
Would like to briefly remind you that the Trevize by name here is not the Trevize of Achaea. Rather, the latter is Fadedparadox here. Since you seem to know the latter, at least by his work, I didn't want you to get confused. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Kevnuke
USA (145 posts) Bio
|
Date
| Reply #12 on Tue 23 Feb 2010 10:58 AM (UTC) Amended on Tue 23 Feb 2010 11:02 AM (UTC) by Kevnuke
|
Message
| ah thanks for the heads up, i did think it was kinda strange that he was having trouble with something so easy.. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
45,116 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top