How to make the wait command value based on Variable ?

Like the title suggest i am looking for ways to a wait command that based on variable value,
i found a way for that here
Example: $gameMap._interpreter.wait($gameVariables.value(1));
this method worked for me with in map event, but when i used in parallel common event it didn't,
to clear things i made an event that call 2 common parallel events, when i used a normal wait command it worked for me but when i used this method it didn't .
my question is there nother way to do a command wait based on variable value ?
or this way i used can be fixed ?
You should use this.wait($gameVariables.value(1)); instead, which is literally what the Wait command does.

The reason your script isn't working, is because it calls the wait command for the current $gameMap._interpreter, which is responsible for all regular events and autorun events, but not for Parallel Process ones.

In order for Parallel Process events to not be blocked by and not block other events, they each have their own personal interpreter. When you use a Script command, your Script command is already running inside the interpreter, therefore you can simply use this instead of $gameMap._interpreter to access the current interpreter.


Think of the interpreter as a car. Whenever an event wants to run, it needs to take the car. However, there is only 1 "public" car, which all events share. This means that only 1 event can run at any given time. Parallel Process events, on the other hand, have their own private cars, so they can run whenever they want, no matter what other events are running.

Currently, your script is addressing the "public" car rather than whichever car the event is currently using. For the most part this works, because it just happens to be the car most events use anyways. But since Parallel Process events only use their own "private" cars, the script doesn't affect them.
You should use this.wait($gameVariables.value(1)); instead, which is literally what the Wait command does.

The reason your script isn't working, is because it calls the wait command for the current $gameMap._interpreter, which is responsible for all regular events and autorun events, but not for Parallel Process ones.

In order for Parallel Process events to not be blocked by and not block other events, they each have their own personal interpreter. When you use a Script command, your Script command is already running inside the interpreter, therefore you can simply use this instead of $gameMap._interpreter to access the current interpreter.


Think of the interpreter as a car. Whenever an event wants to run, it needs to take the car. However, there is only 1 "public" car, which all events share. This means that only 1 event can run at any given time. Parallel Process events, on the other hand, have their own private cars, so they can run whenever they want, no matter what other events are running.

Your script addresses the "public" car, not the one the event is using. For the most part this works, because that's the car most events use anyways. But since Parallel Process events only use their own "private" cars, the script doesn't affect them.
Thank you ! this worked for me,
to be honest with you i don't understand coding that why i use RPG Maker, but you explained this very well,
i also thought there is a porblem with this script call cause it have gameMap and like you said interpreter in it that why i asked if there is other way.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-wait-command-value-based-on-variable.147259/