regexp problem

Posted by Wyd on Mon 19 Jun 2006 05:03 AM — 4 posts, 16,538 views.

#0
Hi all, my second question since I registered!

I have the following line I want to trigger on

You sense a connection between room1 and room2.

The problem is that room1 and room2 may contain multiply words, and the expression may extend over multiply lines...so for a more specific example:


You sense a connection between Twisted path past a dwarf tree (house) and 
Gemstone vials of Moghedu.


or


You sense a connection between Southern Balcony (house) and River Zaphar 
through forest.


Is there anyway to match this, or am I being to hopefull?

Thanks!
Australia Forum Administrator #1
The simplest thing is a multi-line trigger, which are notorious to get right, because of the possibility of multiple matches. This seemed to work for me from your examples:


<triggers>
  <trigger
   enabled="y"
   lines_to_match="3"
   match="(?s)^You sense a connection between ([^.]+) and ([^.]+)\.\Z"
   multi_line="y"
   regexp="y"
   send_to="2"
   sequence="100"
  >
  <send>Wildcard 1 = %1
Wildcard 2 = %2</send>
  </trigger>
</triggers>


The wildcards may end up with newlines in them (because the text had a line break) but you can do a replace to get rid of those.

Example:


You sense a connection between Southern Balcony (house) and River Zaphar
through forest.
Wildcard 1 = Southern Balcony (house)
Wildcard 2 = River Zaphar
through forest



This matched OK, now by replacing the newlines by spaces in the wildcard you would get the room name without breaks in it.
#2
Thanks for that.


One last question...if I create a trigger with a certain name, and then attempt to make another with the same name, will it overwrite the original one, cause me to have two triggers, or not create the second one?

Australia Forum Administrator #3
Using the GUI interface, or a script, you can't add a trigger of the same name, *unless* (in a script) you use the flag:

const eReplace = 1024 ' replace existing trigger of same name