Execute event once when map changes.

I'm trying to make a system that will check if variable "shadow" is on High(1) or Low(2).
If it be High, show normal shadows made by Khas Lighting. If low, it will show a, almost transparent black image over the screen, with a totally transparent circle in the player position.

To do so, i need a common event to check, just once, when i change from a map to another, wich option is being used.

Right Now i'm doing it by a parallel common event, but it will keep checking all the time and probably lag the game a lot for doing so. Autorun works even worse, since it autorun many times that same common event, as the switch that will trigger it is always on.

What can i do? How to check, only once per map change, this variable?
it would be better if you added a check to the plugin itself, so that *it* will handle the configuration.
by default, most plugins will inject themselves into the flow of the program, so, that check for self configuration is already happening.

you should link all checks you need to do, to that routine.
it would be better if you added a check to the plugin itself, so that *it* will handle the configuration.
by default, most plugins will inject themselves into the flow of the program, so, that check for self configuration is already happening.

you should link all checks you need to do, to that routine.
The problem is, the event uses many "show picture" and "move pictures". I've no idea how to implement that in a plugin.

Also, Khas need to fix a bug in the lighting(when lights are disabled, everything turns black on map change), so i would need to add this and then add again in a new update .


Is there a way to turn a switch on just once in every map change?Then maybe i could make things work the way i need to(since the common event would trigger once then turn itself off)
I'm thinking.... but either way I look at it, it all comes down to linking the game back to the plugin somehow. By code.
I mean, if you want it to run once on map change, you'll have to listen for the map change, by code.
if you want it to run by switches, you'll have to link the plugin to the switches library, which is not usually connected. (also, by code)

doesn't Khas have a support website?
I'm thinking.... but either way I look at it, it all comes down to linking the game back to the plugin somehow. By code.
I mean, if you want it to run once on map change, you'll have to listen for the map change, by code.
if you want it to run by switches, you'll have to link the plugin to the switches library, which is not usually connected. (also, by code)

doesn't Khas have a support website?
He does, but probably i won't get an answer from him before the end of the year.

Is there a way to turn a switch on, by a javascript, once(And only one time) i change map?If so, it solves the problem, since i will be able to autorun the common event once and then turn the switch off again.
exactly what I was thinking.

you should be able to add a switch ON call to scene_map.start, and cause the event to run, and have the event take the switch OFF.
Code:
Scene_Map.prototype.start = function() {
    Scene_Base.prototype.start.call(this);
    SceneManager.clearStack();
    if (this._transfer) {
        this.fadeInForTransfer();
        this._mapNameWindow.open();
        $gameMap.autoplay();
    } else if (this.needsFadeIn()) {
        this.startFadeIn(this.fadeSpeed(), false);
    }
    this.menuCalling = false;
  $gameSwitches.setValue(1, true); // <<<<<
};

since start runs before any update, and parallel events only run on map update, as soon as you drop on the map, the event will run, and turn itself off.

double-check it tho..... my JS is kind of off.
I pretty much always have an Auto-run event called Init or Initialize on every map. It runs when you enter the map and does all of the pre-processing for that map. Anything that needs to be run on more than a few maps are put in Common Events.
I don't think it worked, since when i turned if off game still didn't update shadows.

But i also don't know how to check the switch on console....

I pretty much always have an Auto-run event called Init or Initialize on every map. It runs when you enter the map and does all of the pre-processing for that map. Anything that needs to be run on more than a few maps are put in Common Events.
That's why i need an common event, it's going to check on every map. But i can't use parallel process, since it will lag the game(at least, a bit)

EDIT: it worked, my bad. I was starting in a map that i didn't configure yet.Anyway, how do i check a switch on the console?
F9 will bring up a list of all of your switches and variables when running in dev mode. You can see what values everything has there. Your Common Event shouldn't need to run as a parallel process, though. You can just call it in your Init auto-run. It'll run when you first enter the map and then be done until you enter another map when it gets called again.
F9 will bring up a list of all of your switches and variables when running in dev mode. You can see what values everything has there. Your Common Event shouldn't need to run as a parallel process, though. You can just call it in your Init auto-run. It'll run when you first enter the map and then be done until you enter another map when it gets called again.
I really forgot that lel
Anyway, thanks everyone. Working with a much better performance now!
mind you, if you do it through code, you only need to add the instruction once, and it will work for every map.
that's what the code is there for, to take care of things that affect the whole game.

Original thread: https://forums.rpgmakerweb.com/threads/execute-event-once-when-map-changes.88536/