I have *no* idea what is happening here
I have a common event with simple JavaScript that checks six variables, gets the highest, then turns a respective switch on for each one. Despite it working fine for several days, now whenever the event runs, the game chugs so hard it becomes unplayable. The code is only a few if statements, I can't imagine why the game is having so much trouble running it.
I'll post the code, I know it's ugly or whatever but it worked fine until recently! Is the for loop iterating infinitely?
(EDIT: The variables are referencing custom parameters from the Eli plugin)
You'll need to post screenshots of the common event and anything related to it running - such as the event that is calling the common event.
Alone, there is nothing we can do to help you with this.
I think I can be pretty confident in saying that the issue does not lie in the code you posted.
You still haven't shown the common event. How is it triggered? Is it autorun or parallel? Is it called from an autorun or parallel map event? That could be very important information.
It seems quite plausible that the trait change common events could be the cause, but you haven't given enough information.
In my experience game always lags when i forget to put a stopper on loops.. like wait 1 frame.
for what I see in your code is that the switch stays ON.
where is it turned off?
once you turn on a switch, you need to turn off the other or all 3 will run.
I made a switchGroup plugin, so only 1 can be on in this case, not all 3.
this can be useful in your case, and make it a group, if one of them is ON,
the other 2 will be false, (you can add that the other 2 is false, so they wont
be on. (6 extra lines).
but you keep them on, run all 3 common events.
This is unrelated, but I see your troop event is set to run once every 99 turns. Do battles even last that long? If you only want it to run once, you can set the repetition value to 0.
ShadowDragon's observation seems plausible – perhaps those trait common events are running every frame. If that's not what you want, the common events should each turn off their own switch.
Note that, by default, autorun common events do not run during battle. I don't know if VisuStella changes this though.
if you want to control the switch, you can use a conditional branch to run once.
if switch 1 = off
switch 1 is ON
do your stuff
else do nothing here until its off and recalled it)
end
while the trigger is none, it will never be called.
you can turn off switch 2 and 3 there too when its turned on.
but we have low screenshots how you try to connect them all,
so we need full screenshots, not cropped one, so we can see the entire link.