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 ➜ VBscript ➜ Multi Line trigger help

Multi Line trigger help

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


Posted by Ignis   (26 posts)  Bio
Date Sat 16 Nov 2013 07:15 PM (UTC)
Message
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)
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 17 Nov 2013 10:09 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ignis   (26 posts)  Bio
Date Reply #2 on Tue 26 Nov 2013 06:14 AM (UTC)
Message
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>


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.


17,148 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.