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.
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.
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?)
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.
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.
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.
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.
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.
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.