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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  A more complicated trigger than I am used to

A more complicated trigger than I am used to

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


Posted by Anthonyl   (2 posts)  [Biography] bio
Date Mon 30 Oct 2023 01:29 PM (UTC)
Message
Hi, I am trying to parse a phrase from the MUD, and not sure how to do it. I wonder if someone could help me come up with the trigger. I am used to basic triggers, so if my client spits out:

"You need to get paint from the shed and give it to Boris by 4pm"

My trigger text is:
You need to get * from the * and give it to * by *


and in my send to script below I use:

  SetVariable ("item", "%1")
  SetVariable ("location", "%2")
  SetVariable ("customer", "%3") 


top set my variables. I ignore the last *, I am not bothered about the time.


I have a more complicated one, and I don't know how to parse it.

My client spits out "I need you to get 4 green flowers and a navy blue jacket from the boat" and I want to store some of it in variables.

Now, I need to get the number of flowers for one variable, the color of the flowers (which may be 1 or 2 words, a hundred different color possibilities exist) for the second variable, the color of the clothing for the 3rd variable (again 1 or 2 words), and the clothing type (will be jacket, shirt, boots, or britches). But because some arguments are next to others, I don't know how to do this. If the arguments were seperated I could do it with my very basic trigger understanding, but I can't figure this one out.

Any help with how to phrase my trigger would be very appreciated.
[Go to top] top

Posted by Fiendish   USA  (2,519 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Mon 30 Oct 2023 04:04 PM (UTC)

Amended on Mon 30 Oct 2023 04:06 PM (UTC) by Fiendish

Message
Perhaps something like


<triggers>
  <trigger
   enabled="y"
   match="^I need you to get (\d+) (.+) flowers and a (.+) (jacket|shirt|boots|britches) from the boat"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>print("%1")
print("%2")
print("%3")
print("%4")</send>
  </trigger>
</triggers>




Receiving "I need you to get 4 green flowers and a navy blue jacket from the boat"

prints...

4
green
navy blue
jacket


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Anthonyl   (2 posts)  [Biography] bio
Date Reply #2 on Mon 30 Oct 2023 04:52 PM (UTC)

Amended on Mon 30 Oct 2023 04:53 PM (UTC) by Anthonyl

Message
Thanks Fiendish. After asking this question, I went away and tried to learn some regex stuff myself, and came up with my own solution.

I used


^I need you to get (?P<number>\d) (?P<maincolor>.*) (?P<type>flowers|plants|bulbs) and (a|an) (?P<othercolor>.*) (?P<clothing>jacket|shirt|pair of boots|pair of britches) from .*$


Sorted it out now, thanks for the awesome program and helpful forum.
[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.


1,467 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 HostDash]