In this video, you will program the character
to ask the audience the first question
for your interactive story.
On day two, you used a say block to create dialogue.
The say block in Scratch makes a character say something.
However, it cannot receive a response from the audience.
The ask block also makes a character say something.
But unlike the say block,
it collects an answer from the audience using a text box.
You will make your story interactive using the ask block.
To get started, click Sensing and drag out an ask block.
Test the block by clicking on it.
You'll see that the sprite asks, "What's your name?"
and a box pops up at the bottom of the stage.
Click the stop sign to stop this code.
Then change the text of the question to something like,
"Would you like to go through the secret door?"
Test this again.
You'll notice that again, a text box appears
where a user can type his or her answer.
The text a user enters in the box
is stored in a variable called answer.
In computer science, a place in the code that stores a value
or information like a user's text is called a variable.
Click the checkbox next to the answer variable
to see what's stored there.
To test it, click the ask block, then type an answer,
and press enter on your keyboard.
You should see the answer you entered
stored into the answer variable.
If you run the code again, and enter a different answer,
the new answer will replace the old one.
Now it's your turn.
Add an ask block to your program.
Then change the text to ask the user
whether he or she wants to enter the secret door.
Then finally test your code by typing in different answers.
Watch the value of the answer variable change.
In the next video, you'll program your story
to make a decision based on the audience's answer.
Sign in to save your project and track your progress.