Multi-line trigger problem

Posted by Obby on Tue 13 Oct 2015 07:15 PM — 3 posts, 14,117 views.

#0
Hi all,

Trying to write a trigger that will fire on a room output, will start with a short desc in [] and then up to 4 new lines, then a line with exits, then a line with the people/npcs in the room.

I need it to fire only in this circumstance, as scrying a room will output the same exits/people there, hence all the extra complication.

At the moment I have:


  <trigger
   enabled="y"
   expand_variables="y"
   keep_evaluating="y"
   match="^\[(.*)\](\n(.*)){0,8}\nThere (is|are)(.*) obvious exits?(.*)\n(?P<followers>.*)\.$"
   regexp="y"
   send_to="12"
   sequence="100"
   multi_line="y"
  >


The room output looks like this:


[Room Short Desc with map below]
      |   
      *   
     /|\  
    @     
   /      
 -$       
  |       
Room Description Here.
Possible weather line.
Possible other newline(s).
There are two obvious exits: northeast and southwest.
Person One, Person Two, Person Three, Person 4 and Person 5 are standing here.



I guess I could try and do a negative lookback on the lines that preclude scrying but that'd be just as complicated :) Any help would be appreciated!

Oh and I'm pretty new to writing regexp, so there may be a lot of newbie errors in that.. I had it working for just the two lines but having trouble extending it to work as I want it to.

-Obby
Amended on Tue 13 Oct 2015 08:00 PM by Nick Gammon
Australia Forum Administrator #1
I tend to steer away from multi-line single triggers for complex situations because it is hard to get them to fire properly. If you make them match too few lines they might miss something, and if you make them match too many you might get double hits.

Template:faq=37
Please read the MUSHclient FAQ - point 37.


I would be going down that path. Detect the start of a room name, skip the map with a second trigger, and so on. I think I used something similar for one of the mapper versions I did.
#2
Aha that's quite a lot easier, I'll get on that!

Thanks for the prompt reply, and for all your work on this awesome client :)

-Obby