Randomized wait? [SOLVED]

I'm trying to do a random wait. Got this script call for wait from a reddit post but it's not quite working as expected :/ I want to generate a random number from a range... say 200-700. Then I want the event to wait for that amount of frames.
Edit:
I tried this script call for the wait: $gameMap._interpreter.wait(frames)
where and how did you use that call?

The problem here is most likely because there is no wait at all, the event command works differently than most people assume - which is also the reason why waits in a parallel process reduce lag.

Basically all events are objects in the main game loop. and what the so-called wait-command really does is to tell the main game loop "stop processing this object for x loops of the main loop".

So the wait-command only works if correctly attached to an element of the main game loop, otherwise it will have either no effect or the moment the wait is over nothing can be detected.

and to solve your problem we need to know what part of what event are you trying to have waiting.
This is my event page:
1602865609257.png


For context, I'm trying to make randomized lightning and thunder as I don't want it to always occur at the same interval and be monotonous.
Use this in your Script command instead:
JavaScript:
this.wait(200 + Math.randomInt(501));
Your script call didn't work because it targets the main map interpreter, used for non-Parallel events. Parallel events each have their own interpreters. Script commands evaluate in the context of the event's interpreter, i.e. this refers to the relevant interpreter.

I also changed the numbers slightly so that it'll yield a random integer in the range 200~700 inclusive. 🙂
Thank youuu @caethyril I had no idea it was different for parallel and non-parallel events :0 You learn new stuff everyday ^^

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/randomized-wait-solved.128748/