Register forum user name Search FAQ

Gammon Forum

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 ➜ Help with multiline trigger

Help with multiline trigger

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Graymane   USA  (14 posts)  Bio
Date Fri 21 Mar 2014 06:17 PM (UTC)

Amended on Tue 25 Mar 2014 08:08 PM (UTC) by Nick Gammon

Message
I'm trying to get a trigger to match on the room name, Exits, and room description in one go.

My MUD outputs the following:


Some Room Name
[Exits: north south up down]
Some optional room desc line.
More optional room desc lines.
[a blank line here]
optional room contents
<Some Prompt>


I'm trying to match the room name (Some Room Name), the exit directions ("north south up down"), and the optional room desc (all non-blank lines after exits terminated by an empty line).

The following sort of works in that it captures the room name, the exits, and only the first line of the description. Adding an extra '\n' before the '\z' to try to match an empty line does NOT work, however.


<triggers>
  <trigger
   enabled="y"
   group="Mapping"
   lines_to_match="3"
   match="^(.+)\n[Exits: (.+)]\n(.*)\n\z"
   multi_line="y"
   name="RoomDetector"
   regexp="y"
   send_to="2"
   sequence="100"
  >
  <send>print (Room Name: %1, Exits: %2, Description: %3)</send>
  </trigger>
</triggers>




Any ideas? I'm just sort of playing around with different modifiers to this basic setup. I do note that if I add (?s) to it, it grabs everything down to the blank line and then the line right after the blank if there one (usually either the prompt or room contents).

[EDIT] Added code tags.
Top

Posted by Graymane   USA  (14 posts)  Bio
Date Reply #1 on Fri 21 Mar 2014 08:32 PM (UTC)

Amended on Fri 21 Mar 2014 08:33 PM (UTC) by Graymane

Message
I did get a 3-trigger version working. I did discover that my mud's newlines tend work as "^\s*$", rather than "^$".
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 25 Mar 2014 08:15 PM (UTC)
Message
First, here:


[Exits: (.+)]


Since you are matching square brackets you have to escape them, eg.


\[Exits: (.+)\]


Next, since you are saying to match on 3 lines then you won't get lots of lines of description matching.

It's hard to get a multi-line trigger working properly in these situations, your solution of a 3-trigger one is probably the best.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


10,260 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.