MV Opening menu is changing switch #41? Any ideas?

I have a very strange problem with my nearly-complete game.

I am using a plugin for overlay images, which I use to create light, fog and shadows. This plugin has switches, and switch #41 turns the fog layer on and off, making it visible provided the map has a defined fog layer image.

One of my players discovered that on maps which use the fog layer, if they hit <esc> to bring up the game menu, the fog layer disappears. When I check this in the editor, I can see that after I've brought up the <esc> menu, and the layer disappears, Switch #41 is turned OFF (when before, it was turned ON).

This is making me wonder if some other plugin is designed to change Switch 41 to say whether or not the menu is open; I assume for tracking this for some sort of reason. I'm using a lot of Yanfly plugins so maybe one of these?

So I just wanted to ask here, before I start diving into many, many plugins to try and find the culprit - does this kinda spark a realisation with anyone here, and do you know of any common plugins that are meant to do this?
It might be easier to open the plugin.js file with a text editor and search for 41

the plugin.js is where the settings of the plugin manager and all plugins are stored, and if this comes from a plugin it should have an option to give the switch ID used, which will be stored there.

you'll probably get a number of wrong similar results, but it should still reduce the number of plugins that need to be checked.
depends how the plugin is coded and which one in general.

by default it shouldn't turn it off, but freeze it instead.

if in case it does turn it off as it is placed above the windows,
it should turn it on after, but we have no idea what plugin you use for it,
neither do we know your plugin list, which has reference to it.
Thanks for the ideas @Andar , @ShadowDragon .

It turns out the problem is much stranger.

I have a parallel event called ToD in every map, which fires up a common event to set the ToD (tint, etc.) and then erase itself. This way, the ToD sets itself everywhere you go. This works really well. However, this ALWAYS turns the fog variable OFF (because I don't use it anywhere else in the game).

So you'd think that would mean the fog would never work - but it doesn't.

I believe what's happening here is an order of execution thing, where upon entering the map with the fog, the fog is being turned on (on-load) and its switch is being turned OFF, but this happens in such a way that the plugin doesn't "notice" the switch being turned off. Then, opening/closing the menu causes the overlay plugin to "notice" and turn the fog off.

Thanks for your help, your suggests did lead me to the eventual answer.

Original thread: https://forums.rpgmakerweb.com/threads/opening-menu-is-changing-switch-41-any-ideas.176767/