Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Is there a "wait" command in RGSS?

Is there a command in RGSS that allows you to "pause" the script for a certain time frame and the execute the rest of the script when that time frame is up?


Example:

I want a box to stay open for 5 seconds. I make a script and tell it to open then "wait" 5 seconds and close. Is that possible?
 
there are two ways

you can use
sleep(seconds) to pause the script

or you can do this

in the main method add this
Code:
@wait_count = 0

in the first lines of the update method add this
Code:
if @wait_count > 0
  @wait_count -= 1
  return
end

and then whenever you want to wait do this
Code:
@wait_count = frames

where frames is the number of frames to wait

in your case you want
Code:
@wait_count = 5 * Graphics.frame_rate

and that'll be five seconds (or you could estimate and say 100)

but I really prefer the second method over the first
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top