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 ➜ Lua ➜ Lua Trigger

Lua Trigger

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


Posted by Barg   (2 posts)  Bio
Date Sat 19 Mar 2011 02:30 PM (UTC)
Message
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="Multi Line"
lines_to_match="2"
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"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>Note("hi")</send>
</trigger>
</triggers>


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?
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #1 on Sat 19 Mar 2011 06:25 PM (UTC)
Message
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.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Barg   (2 posts)  Bio
Date Reply #2 on Sat 19 Mar 2011 06:47 PM (UTC)
Message
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.
Top

Posted by Manacle   (28 posts)  Bio
Date Reply #3 on Sun 20 Mar 2011 12:49 AM (UTC)
Message
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.

Or

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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 20 Mar 2011 01:37 AM (UTC)
Message
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
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.


21,931 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.