In this exercise, we will use the Open Roberta editor. Make sure that you see this picture in the upper right corner of your programming environment. The editor can be found on our website at the top of the navigation bar: Let's start - Editor.
First steps: Fortune telling ball
Your Calliope mini knows the answer.
First, you create a variable. Click on the + symbol in the Start block. Then name the variable with random.
To display a question mark at the start of the mini, take the show text block you find under action, change text to character and enter a question mark.
Select the following block in the menu under control to play your following code in an endless loop.
Now select the if - do block under control to set the condition. Then add the get shaking gesture from the sensors menu to control the position sensor. In the selection change upright to shaken.
Next, select the set random block from the variables menu. To these you add the integer random value between 1 and 100 block, from the math menu, change the 1 to a 0 and the 100 to a 3.
Now the value of the variable random is randomly set to a number from zero to three.
Now add another if - do block and add the block = from the logic menu to it. Now you fill the block with the random variable, from the variables menu and a 0 to set the condition for the value zero of the variable. Then take a show text block and enter your answer in the text box.
You can duplicate this if - do block four times. To do this, right-click on the if - do block and choose copy. For the further random numbers 1-3 of your duplicated blocks you can now define the statements. In each of the three blocks, make the following statements:
- change the random number
- enter your text
- put your blocks together
To have a little time to display the next answer, you can insert a pause. To do this, use the Wait ms block, which you can find under Control. Try different wait times until you find a period you like.
To display a question mark after the answer again, add a show text block at the end. Now all you have to do is change text to characters and enter the question mark in the text field.
Done - download your script and try it out!