In the previous video,
you programmed lightning to flash.
The lightning isn't that predictable,
and it doesn't flash on command.
In this video, you'll learn how to program the lightning
to flash randomly throughout your story.
To start, place a forever block around the repeat block.
This should make the lightning repeat for the entire story.
Click the green flag to test it.
Whoa, that's way too much lightning!
You told the lightning strike
to repeat over and over forever, and it did.
Now you just need to make the computer wait
before it runs the loop,
creating breaks between lightning strikes.
Now, you'll add a wait block before the repeat block.
Change the value to however long you want to wait
between lightning strikes in your story.
Click the flag to try it again.
Great, when you click the green flag,
the computer enters this forever loop.
Its first action is to wait four seconds
and then it runs this repeat block
to make the lightning strike.
Once it has completed the inner loop,
the computer goes back to the outer loop,
waits four seconds, and then starts again.
Lightning now strikes every few seconds in your story.
In nature, however, lightning doesn't strike in a pattern.
Sometimes there might be one second between strikes,
other times the interval may be much longer.
To make your story setting more realistic,
make the computer wait for a random amount of time
between lightning strikes.
From the Operators menu, choose a pick random block
and place it inside the wait block.
Every time this block runs, it will select a random number
between the two numbers you specify.
Test this and tinker with the values.
You might feel like a 10 second wait is too long,
or that waiting one second is too short.
This example will use two and six seconds.
This means that the lightning strikes could occur
at any interval between two seconds and six seconds.
Great, in the next video, you'll program a story
to take place within this rainy day setting.
Now it's your turn.
First, add a forever loop to make lightning strikes
keep happening forever.
Second, add a wait block to wait between strikes.
Third, add a pick random operator
to make the lightning random.