Lua Trigger

Posted by Barg on Sat 19 Mar 2011 02:30 PM — 5 posts, 23,015 views.

#0
<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?
USA Global Moderator #1
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.
#2
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.
#3
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.
Australia Forum Administrator #4
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.