Randomized wait? [SOLVED]

Status
Not open for further replies.

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
960
Reaction score
2,247
First Language
Not English
Primarily Uses
RMMV
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)
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,433
Reaction score
7,712
First Language
German
Primarily Uses
RMMV
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.
 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
960
Reaction score
2,247
First Language
Not English
Primarily Uses
RMMV
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.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,117
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
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. :)
 

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
960
Reaction score
2,247
First Language
Not English
Primarily Uses
RMMV
Thank youuu @caethyril I had no idea it was different for parallel and non-parallel events :0 You learn new stuff everyday ^^
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,479
Members
137,824
Latest member
dobratemporal
Top