differentiate Simulate from received packets

Posted by Fiendish on Mon 02 Nov 2015 08:56 PM — 2 posts, 11,596 views.

USA Global Moderator #0
Following upon http://www.mushclient.com/forum/?id=12328 I also find myself wanting calls to Simulate to not trigger OnPluginPacketReceived. Can Simulate take an optional second argument for that? (Or maybe make a new function that does this claled something other than Simulate?)

obscure reasoning that depends on interplay between multiple plugins written by different people:

This is due to a combination of how useful Simulate is in practice and the fact that OnPluginPacketReceived is unaffected by plugin sequencing and StopEvaluatingTriggers.

Example:
One plugin takes the line "Hello, my name is Fiendish" and changes "Hello" to "Bonjour". The result is "Bonjour, my name is Fiendish". It omits from output and then uses Simulate to generate new output and then does StopEvaluatingTriggers(true) so that other things can trigger/omit/repeat on the same line without duplicating output (common problem with people doing multiple same line replacements).

A second plugin wants to blast changes into every packet received from the server so that it can easily adjust both displayed messages and also gmcp data without having to do anything with style runs, so it uses OnPluginPacketReceived. One of the things it wants to change is from "Fiendish" to "Fiendish (ButtHead)". On its own this works quite well. But when the other plugin runs and sees "Hello, my name is Fiendish (ButtHead)" and changes that to "Bonjour, my name is Fiendish (ButtHead)", the second plugin matches again on the new output (because it's looking for Fiendish and seeing it again on output produced by a plugin but not sent by the server) and changes the just-simulated packet to "Bonjour, my name is Fiendish (ButtHead) (ButtHead)", which is bad.
Amended on Tue 03 Nov 2015 03:11 AM by Nick Gammon
Australia Forum Administrator #1
Added a GetInfo (123) call that lets you detect if the current input is being simulated or really arrived from the MUD.


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