[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Multi Line trigger help
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Multi Line trigger help

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


Posted by Ignis   (26 posts)  [Biography] 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)
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Ignis   (26 posts)  [Biography] 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>


[Go to top] 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.


3,264 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]