MV Turn a plugin ON and OFF in game?

Is it possible to turn a plugin ON or OFF in game?
ShadowDragon swears this works in "most cases"

if ($gameSwitches.value(x)) { // if x = ON, you can use the (script in the plugin), else not

on the bottom of the function before })() if present

}

and that should activate the plugin or not 🙂 in most cases, this does work,
sometimes it doesn't.
no
that would be like working on your car's engine while driving on the highway.

what can be done is to use internal code prepared to shut off functions of a plugin while the plugin itself remains on - and that needs to be programmed in by the plugin writer.
If the plugin writer did not include such options, nothing can be done without rewriting the plugin
i didnt try it, but like aqua echo mentioned..

if editing a plugin and puting almost everything in the "if condition" that the switch must be active.. than these plugin functions will only be active if the switch is on..

but that should also depend on what kind of plugin you use..

.. by default most plugins dont have such option, so you might need to edit the plugin which you want to work that way and try it out

edit..

and like andar explained, this solution wont turn the plugin off, it will only deactivate the plugins functions which were put in that switch-condition.. the plugin itself will still be read by the system..

edit2..

if the plugin you want to edit and disable that way is encrypted and has strong terms like for example "visualstella-stuff" or similar, than you can forget it^^
The problem with the technique @AquaEcho and @dopan suggest is function definitions are parsed from the code files when they're loaded, not during runtime.

That's why if you make modifications to a plugin, you have to reload it in your plugin manager, save your project, and start a new game to see the changes reflected. Same thing if you completely add or remove (or turn on/off) a plugin.

The contents of each function can be wrapped inside a conditional, but if you don't know what you're doing and know exactly which lines are actually changing something from the original code or calling another new function in the code...it'll just break.

You can do a really simple test. Include this as a plugin:
Code:
if ($gameSwitches.value(1))
{
    TurVariable = function()
    {
        $gameVariables.setValue(1, 10);
    };
}

So the script call TurVariable() would set variable 1 to the value 10, but only if game switch 1 is turned on.

Except if you try to test it, you're going to get a reference error to an undefined function, because the code has to be parsed when the game boots and the conditional is not true at that point.

(in fact, the plugin itself shouldn't even load because that data structure doesn't exist at the point the engine is reading the plugin files)
Is it possible to turn a plugin ON or OFF in game?
More specifically, what kind of plugin do you want to turn off and on in-game, and what effect are you hoping to achieve by doing it? More info might lead someone to an idea for a workaround!
well of those who answered here att_turan has probably the most JS knowledge (which means i am not trying to argue who is right or wrong, cos i have less JS knowledge for sure^^), and i tried to explain it as simple as i could, but i think the best way to solve your question would be to show the plugin which you want to enable/disable, so that someone could read it and try to add a switch condition to the main trigger of what you want to enable/disable..

(so that most part of the plugin is still working except the final trigger of the stuff that you want to enable/disable)

of course only if the plugin terms allow it and like i said it depends of the plugin so this solution can work for some but probably not for all plugins..

also it might be interesting to know why you want to enable/disable it, because if its about plugin compatibility there might be other better solutions
simple plugins work with simple switch check, advanced is mostly likely
more modification like ATT_Turan said on parsing them.

but I did it on the simple once mostly without issue, advanced plugin
throws an error and need some more coding to it.

depending on how the plugin works and not encrypted, some has an
disable/enable plugin (like shora's lightning plugin).

this definitely DOES NOT work if the code doesn't have the proper functions.
so for higher compability to make it work is to ask the author of the plugin for
a way to enable/disable the plugin, but you can also check if the switch is false
so it it is enable on boot, but this require testing.

advanced plugins doesn't work right away in a if statement, simple and small
plugins mostly (for what I tested).

but more details on which plugin and how/where (like options settings)
require much more code than just a simple "if statement".
Thank you for all the replies. I found another solution which seems to work so far.
It was a conflict between YEP's message core and Galv's message plugin.

Original thread: https://forums.rpgmakerweb.com/threads/turn-a-plugin-on-and-off-in-game.164623/