• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How do I put a few seconds delay in a script to pause an event in the code?

  • Thread starter Vanavah Edwards
  • Start date
V

Vanavah Edwards

Guest
In my code, I want to delay printing to the screen until an event is complete. How do I go about doing that?
 
B

bojack29

Guest
Well, the draw event runs lastly among the rest of your scripts. So wouldnt that work?
 

JPDamstra

Member
Simply wrap your draw event code in a Boolean condition.

E.g.
CREATE event:
codeComplete = false;

STEP event:
//start of the script
.
.
.
// some stuff happens around here
.
.
.
codeComplete = true; // script has finished running
// end of the script

Note: You could set codeComplete to true via an alarm as most likely the above code will execute way faster than a couple seconds.
E.g.
.
alarm[0] = room_speed * 5; // execute alarm[0] script after 5 seconds
// end of the script

ALARM[0] event
codeComplete = true;

Lastly, in your DRAW event:
if (codeComplete == true)
{
draw_text(50, 50, "Code has been completed!");
}
 
Top