Multi Line trigger help

Posted by Ignis on Sat 16 Nov 2013 07:15 PM — 3 posts, 20,925 views.

#0
I'm trying to log something like the following to a file. however I never seem to get a successful match.


You examine a scroll carefully.
Object 'scroll' is type scroll, extra flags magic.
Weight is 1, value is 0.
Level 13 spells of: 'armor'.


the match I have is:

<triggers>
  <trigger
   enabled="y"
   group="Multi Line"
   ignore_case="y"
   lines_to_match="6"
   keep_evaluating="y"
   match="You examine * carefully.\nObject '*' is type *, extra flags *.\n*\nHas * charges of level * '*'.\n"
   multi_line="y"
   regexp="y"
   send_to="2"
   sequence="100"
   lowercase_wildcard="y"
  >
  <send>world.note "%2, kwds:%3, type %4, extras %5,  %7 x lvl %8 %9"</send>
  </trigger>
</triggers>


In the end I plan to do something more elaborate with the information I'm pulling, but having a hard time getting started retrieving said information. I also tried copying the above example of what i'm trying to match into test trigger and still no luck. Has anyone else had this trouble before? (Tried searching the forae and didn't seem to have any luck)
Australia Forum Administrator #1
Template:regexp
Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.



Object '*' is type *


You probably mean:


Object '(.*)' is type (.*)


Wildcards work differently when you use regular expressions.
#2
Ah, that helped greatly. I also learned a good deal about named wildcards


<triggers>
  <trigger
   enabled="y"
   group="Multi Line"
   lines_to_match="4"
   keep_evaluating="y"
   match="^You examine (?P&lt;short&gt;.+?) carefully\.$\n^Object (?P&lt;key&gt;.+) is type (?P&lt;type&gt;.+), extra flags (?P&lt;flags&gt;.+)\.$\n^Weight is (?P&lt;weight&gt;.+), value is (?P&lt;gold&gt;.+)\.$\n^Has (?P&lt;charges&gt;.+)\((.*)\) charges of level (?P&lt;splvl&gt;.+) (?P&lt;spellname&gt;.+)\.$"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
   lowercase_wildcard="y"
  >
  <send>world.note "%&lt;short&gt;, kwds:%&lt;key&gt;, type %&lt;type&gt;, $%&lt;gold&gt;, %&lt;charges&gt; xlv %&lt;splvl&gt; %&lt;spellname&gt;"</send>
  </trigger>
</triggers>