[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]  Lua
. . -> [Subject]  Lua Trigger
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

Lua Trigger

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

Posted by Barg   (2 posts)  [Biography] bio
Date Sat 19 Mar 2011 02:30 PM (UTC)
group="Multi Line"
match="You eat (a|an|some) (bayberry|bellwort|bloodroot|ginseng|goldenseal|hawthorn|lobelia) (bark|seed|berry|root|leaf|flower)\.\n[^The plant has no effect\.]\Z"

Okay, for the above I am trying to match on some of the plant eating messages that either do nothing right away, or cure something. Just anything (on the 2nd line) except when "The plant has no effect." and I plan to make a second one for the ones that aren't covered by it.
Doesn't seem to match, though what am I doing wrong?
[Go to top] top

Posted by Fiendish   USA  (1,744 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Sat 19 Mar 2011 06:25 PM (UTC)
We can't properly help you without knowing what the output from your MUD looks like. Please paste examples of the exact lines that you are trying to match.

[Go to top] top

Posted by Barg   (2 posts)  [Biography] bio
Date Reply #2 on Sat 19 Mar 2011 06:47 PM (UTC)
You eat a bellwort flower.
You eat a bloodroot leaf.
You eat a ginseng root.
You eat a goldenseal root.
You eat a hawthorn berry.
You eat a lobelia seed.
You eat some bayberry bark.

These two underneath, I'll use a different trigger to match, but basically the same in concept to the original trigger posted.

You eat some prickly ash bark.
You eat a piece of kelp.
[Go to top] top

Posted by Manacle   (28 posts)  [Biography] bio
Date Reply #3 on Sun 20 Mar 2011 12:49 AM (UTC)
Are you sure the second line should be in brackets?

You could also make this a two part trigger.

Match the eating herb line in the first one and set a flag (herbeaten variable, for instance).

Then you can either:

Have a set of triggers. One with priority (say) 80 that matches the "no effect line" and one with a higher priority than the previous two (say, 110) that matches anything. The first one does whatever you want this trigger to do, but all the second one will do is clear the "herbeaten" variable.


You can have just one other trigger that matches the "no effect line". I am assuming with this option that you'd never get the "no effect" line without having eaten an herb just before that. You could also use timestamps to filter out "no effect" lines that aren't immediately preceded by having eaten a herb, but at that point I think you'd be better off putting more effort into getting the single trigger to work.
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sun 20 Mar 2011 01:37 AM (UTC)
This part is definitely wrong:

[^The plant has no effect\.]

That defines a "set" which matches any single letter *not* in the words "The plant has no effect.". So it would match a single "m" for example. You mean round brackets.

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.

However I'm inclined to agree with Manacle that you want two triggers. One matches the plant you just ate (one line). And remembers what it was. And then if you get "The plant has no effect." you just re-eat that last plant, which you remembered.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


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.


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]