Toggle plugin on/off with control switch

Alright - you've got something weird happening here. What exactly is this._encounterMeter?  Look at what you're doing with it:

Code:
this._encounterMeter = $gameSwitches.value(20);
...
this._encounterMeter.refresh(gauge_value, gauge_max);    //Line 49
...
this._encounterMeter = new Encounter_Meter(gauge_value, gauge_max);

By putting this._encounterMeter = $gameSwitches.value(20) you are setting the value of _encounterMeter to true or false, you are not setting the visibility of an Encounter_Meter type of object.  So get rid of that line from there, then go into the Encounter_Meter.prototype.refresh function, and add this:


this.visible = $gameSwitches(20);


I'm not actually sure if that's the correct syntax - could be this._visible or something else.  I don't have the MV scripts open in front of me.
Alright - you've got something weird happening here. What exactly is this._encounterMeter?  Look at what you're doing with it:

Code:
this._encounterMeter = $gameSwitches.value(20);
...
this._encounterMeter.refresh(gauge_value, gauge_max);    //Line 49
...
this._encounterMeter = new Encounter_Meter(gauge_value, gauge_max);

By putting this._encounterMeter = $gameSwitches.value(20) you are setting the value of _encounterMeter to true or false, you are not setting the visibility of an Encounter_Meter type of object.  So get rid of that line from there, then go into the Encounter_Meter.prototype.refresh function, and add this:


this.visible = $gameSwitches(20);


I'm not actually sure if that's the correct syntax - could be this._visible or something else.  I don't have the MV scripts open in front of me.



Ok I put it at the beginning and end with .visible, ._visible, and .visibility and it's still drawn to the screen. Of course the error goes away when removing that line. The switch is set in MV at game start to be disabled, so I don't see an issue there.
beginning and end of what?  You don't need it in both places - only once.  Maybe refresh is not being called on every frame.  Is there an update function?  If there is, put it in there.  If there isn't, find the Scene_Map.prototype.update function and add:


this._encounterMeter.visible = $gameSwitches(20);
beginning and end of what?  You don't need it in both places - only once.  Maybe refresh is not being called on every frame.  Is there an update function?  If there is, put it in there.  If there isn't, find the Scene_Map.prototype.update function and add:


this._encounterMeter.visible = $gameSwitches(20);

That worked!


this._encounterMeter.visible = $gameSwitches.value(20);


Hmm for some reason the encounter happens on my empty test project, but not here. Nothing happens when the gauge is full. And it is counting steps in areas where the gauge isn't visible. I know at least that it works in the test project I had....
Different problem.  I suggest you either have a very close look at what's different between your test project and "here" (wherever "here" is), and if you can't figure it out, make a post in Yanfly's plugin thread.

Original thread: https://forums.rpgmakerweb.com/threads/toggle-plugin-on-off-with-control-switch.58078/