Event Graphic issue If i change self switch by script

Hi all!
I've a event with 2 pages.
Each page have a different graphic and the second page must to be loaded if A self switch event is ON.

I'm changing the self switch value by script using:

Code:
if($gameSelfSwitches.value([2,1,'A'])){
   $gameSelfSwitches.setValue([2,1,'A'], false);
}else{
   $gameSelfSwitches.setValue([2,1,'A'], true);
}

It works but if I set On/Off to fast the page's graphic go wronk for an istant!
I've attached a video to show you what i mean...


Why that's happened?!?
funny if it go to a candlelight, but I think its best to put a wait before it can be pressed again,
between 1-4 frames mostly do the trick though.

but it is also depending, does it need to go fast? or only partly (like from 1 hour to 6 hours ON,
6 hours to 12 hours OFF as an easy example?
Aah, the problem I discovered long time ago but no one talked bout until now ~

....
Try set each page direction fix ON.
I studied the matter a little and I have reason to believe that the cause is the fact that the 1st page have a "Step Animated" Graphic and the 2nd Paga is Direction Fix.
Calling the selfSwitch by script the execution is faster than the properties reader of 2nd page so the graphics of the latter go "Step animated" for a second's fraction.

So i've to understand how to solve this by code anyway I can change the charaset of 2nd graphic putting all 3 tiles identical for the "stepping animation of character".
Why are you doing it via script?
Because I am developing a plugin to set multiple selfswitches starting from the name

Ex: all events on the map called "Lantern" turn on and off in one go
Update:

the problem remains even without using the script.
I tried to set SelfSwitch using RPG MV's Editor and if i pass from a page with step_animation graphic to one with the direction fixed graphic the bug remains!

Original thread: https://forums.rpgmakerweb.com/threads/event-graphic-issue-if-i-change-self-switch-by-script.121497/