Call common event via scrip // ORDER?

Hey,


so I'm having an annoying issue and I'm not sure if it's solvable. I'm using the <Custom React Effect> from Yanfly's Buffs & States Core and inside that I call a common event via "$gameTemp.reserveCommonEvent(52);".


My problem is, that this event always is called right after the whole custom react effect code.


A simple example:


Inside the state:


<Custom React Effect>


console.log("1.");


$gameTemp.reserveCommonEvent(1);


console.log("3.");


<Custom React Effect>


inside common event #1 I'm just making a script call with the following inside:


console.log("2.");


Instead of being "1.  2.  3.", the order in the console pops up as "1.  3.  2.". It seems like the commont event isn't called instantaniously but, as I said, after the whole custom react effect.


Does anyone know how to evade this effect, so that the common event is called right on the spot, or if it's even possible?
There is maybe a easier way to do it, but you can probably do something like this :


<Custom React Effect>


console.log("1.");


$gameTemp.reserveCommonEvent(1);


while($gameSwitches.value(1) == false) {


sleep(10);


}


console.log("3.");


<Custom React Effect>


And your common event set the switch 1 to ON at its end.
There is maybe a easier way to do it, but you can probably do something like this :


<Custom React Effect>


console.log("1.");


$gameTemp.reserveCommonEvent(1);


while($gameSwitches.value(1) == false) {


sleep(10);


}


console.log("3.");


<Custom React Effect>


And your common event set the switch 1 to ON at its end.



Ok, so I tried it, but i get a syntax-error on the sleep() funktion. It seems to be not defined.
well, just remove the sleep fonction. It was to avoid free looping.
Tried it out, but it doesn't work. Infiniteloop and the game doesnt respond. Seems like the code of the common event doesn't execute.


Thank you for that suggestion though, now I can most certainly say, that the common event executes after the custom react effect. I guess I'll try to handle it otherwise then.
I think Himeworks has an Event Queue Stack plugin.  I am on my phone so I can't pull the link right now but you might want to look into that. Don't know if it is exactly compatible or not but it could be a start.
I think Himeworks has an Event Queue Stack plugin.  I am on my phone so I can't pull the link right now but you might want to look into that. Don't know if it is exactly compatible or not but it could be a start.



Ty, I'll take a look on it!


Edit: Doesn't do the job either 🙁

Original thread: https://forums.rpgmakerweb.com/threads/call-common-event-via-scrip-order.70573/