How to script call common event immediately?

The script call for calling a common event is the below:


$gameTemp.reserveCommonEvent(n);


However if this is called within another common event the event won't get called immediately but rather will be called after the current common event is finished, which is the wrong order. How can I call a common event immediately by script? It should work the same as using an editor command.
Why are you doing it within a script call when another common event is running?  Why not just use the Common Event command within the initial common event to call the next one?


'Reserve' implies that you're putting it in line to run at the next opportunity, not straight away.
var commonEvent = $dataCommonEvents[COMMON_EVENT_ID];
if (commonEvent) {
var eventId = this.isOnCurrentMap() ? this._eventId : 0;
this.setupChild(commonEvent.list, eventId);
}




Remember to replace COMMON_EVENT_ID by the number of the common event you're calling.
I tried this but it's not working
var commonEvent = $dataCommonEvents[COMMON_EVENT_ID];
if (commonEvent) {
var eventId = this.isOnCurrentMap() ? this._eventId : 0;
this.setupChild(commonEvent.list, eventId);
}




Remember to replace COMMON_EVENT_ID by the number of the common event you're calling.

The common event ID 97 wont run

Code:
for (let i = 1 ; i <= 15; i++){
  if ($gameVariables.value(92)===0 && $gameVariables.value(100)===8 &&$gameVariables.value(60+i)===$gameVariables.value(100)){
    $gameVariables.setValue(97,80+i);
    var commonEvent = $dataCommonEvents[97];
       if (commonEvent) { var eventId = this.isOnCurrentMap() ? this._eventId : 0;
       this.setupChild(commonEvent.list, eventId);}
    $gameVariables.setValue(60+i,$gameVariables.value(60+i)+4);
    $gameVariables.setValue(92,i);
    $gameVariables.setValue(88,0);
}}
Just to note, we're not supposed to necro-post, and this thread is 7 years old.

I would guess your problem is the loop. It looks like you're trying to run the same common event 15 times in the span of a fraction of a second, which probably screws with the engine's queue.
Just to note, we're not supposed to necro-post, and this thread is 7 years old.

I would guess your problem is the loop. It looks like you're trying to run the same common event 15 times in the span of a fraction of a second, which probably screws with the engine's queue.
thanks, but i felt it's the same problem so i thought using the same thread.

how do i solve not to run the common event it's false? i think it should only run once, since the condition can only be met once. but since it's a for loop, yup it will be checked 15 times.
thanks, but i felt it's the same problem so i thought using the same thread.
It's probably not, though. The code for calling the common event was supplied higher up in the thread, so your question is probably not about "what is the code to do this," but "what is the error in my code".

i think it should only run once, since the condition can only be met once.
Sorry, your formatting was a little odd to me so I didn't correctly read that was all inside of a conditional.

So the obvious question is are you sure that the conditional is ever evaluating to true?

Original thread: https://forums.rpgmakerweb.com/threads/how-to-script-call-common-event-immediately.71632/