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 ➜ Bug reports ➜ Multi-line triggers created through AddTriggerEx() don't work

Multi-line triggers created through AddTriggerEx() don't work

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


Posted by Kahenraz   (75 posts)  Bio
Date Sun 15 Apr 2018 12:22 AM (UTC)

Amended on Sun 15 Apr 2018 12:23 AM (UTC) by Kahenraz

Message
Examine the following single-line trigger:

Trigger = [[^You poke (?P<thing>.+)\.$]]
Script = [[print("Poke: %<thing>")]]

AddTriggerEx("Test_Trigger", Trigger, Script,
   trigger_flag.Enabled + trigger_flag.RegularExpression + trigger_flag.Replace
   + trigger_flag.KeepEvaluating, -1, 0, "", "", 12, 0)


It works as it should. See the following test:

You poke a rock.


Output:

Poke: a rock.


Now try the same thing with a multi-line trigger:

Trigger = [[^You poke (?P<thing1>.+)\.$\n^You prod (?P<thing2>.+)\.$]]
Script = [[print("Poke: %<thing1>")
print("Prod: %<thing2>")]]

AddTriggerEx("Test_Trigger", Trigger, Script,
   trigger_flag.Enabled + trigger_flag.RegularExpression + trigger_flag.Replace
   + trigger_flag.KeepEvaluating, -1, 0, "", "", 12, 0)

SetTriggerOption("Test_Trigger", "multi_line", "y")
SetTriggerOption("Test_Trigger", "lines_to_match", "2")


With the following test:

You poke a rock.
You prod a rock.


There is no output. It does not match. However, if I open the trigger in the configuration window -do nothing- and click "OK" then it works as expected with the following output:

Poke: a rock
Prod: a rock


So for some reason these triggers aren't being evaluated when added by AddTriggerEx() and subsequently set as a multi-line trigger with SetTriggerOption().
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 15 Apr 2018 06:46 AM (UTC)
Message
You have discovered a bug in the processing of SetTriggerOption. The latest pre-release should fix that.

https://github.com/nickgammon/mushclient/commit/f99ffb2

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


10,304 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.