StopEvaluatingTriggers broken across plugins outside of SendToScript

Posted by Fiendish on Sat 17 Dec 2016 04:52 PM — 4 posts, 16,107 views.

USA Global Moderator #0
https://mushclient.com/scripts/doc.php?function=StopEvaluatingTriggers implies that using StopEvaluatingTriggers outside of SendToScript _should_ affect other plugins, but that it just won't affect the current plugin. That's fine. That's what I want anyway. Except it doesn't work. The following two plugins together keep printing "test 1\ntest 2" instead of only "test 1"

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="test_trigger_1"
   author="Fiendish"
   id="b0ba651e71e0c226a60ae8f1"
   language="Lua"
   date_written="2014-04-08 09:43:19"
   requires="4.90"
   version="1.0"
   sequence="-5000"
>
</plugin>
<triggers>
  <trigger
   name="all"
   enabled="y"
   match="^(.*)$"
   omit_from_output="n"
   regexp="y"
   sequence="100"
   script="test_1"
  ></trigger>
</triggers>
<script>
function test_1()
   print("test 1")
   StopEvaluatingTriggers(true)
end
</script>
</muclient>



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="test_trigger_2"
   author="Fiendish"
   id="b0ba651e71e0c226a60ae8f2"
   language="Lua"
   date_written="2014-04-08 09:43:19"
   requires="4.90"
   version="1.0"
>
</plugin>
<triggers>
  <trigger
   name="all"
   enabled="y"
   match="^(.*)$"
   omit_from_output="n"
   regexp="y"
   sequence="100"
   script="test_2"
  ></trigger>
</triggers>
<script>
function test_2()
   print("test 2")
end
</script>
</muclient>
Amended on Sat 17 Dec 2016 04:56 PM by Fiendish
Australia Forum Administrator #1
I think you are misreading the implications. As documented here:

http://www.gammon.com.au/forum/?id=6554

"send to script" is done in step 12.

Running functions named in a trigger "script" parameter (not send-to-script) is done in step 20.

In other words, external function calls are remembered in a list, and then processed later. It is too late at that point for such a function to alter trigger evaluation (by doing "StopEvaluatingTriggers").

The documentation for StopEvaluatingTriggers says:

Quote:

This would have to be called from "send to script" (not send-to-script-after-omit), nor from a trigger script file, in order to be effective.


This is correct. There is no implication there that it can be usefully called elsewhere.
USA Global Moderator #2
I'm talking about the part that says (emphasis added)

Quote:
Note that since calling a trigger script (script name in Script box) is done after all triggers are evaluated for that plugin, doing this inside a script file will be too late (for the current plugin). It has to be done in send-to-script.
Australia Forum Administrator #3
That is just saying that each plugin (plus the main world file) are evaluated in turn.

So, script files are called when all triggers are evaluated in all plugins.

I think the documentation might be slightly misleading. "for that plugin" should probably read "for all plugins".