Time for action – creating a custom say fortune block
We're about to duplicate a script, so we're going to take this opportunity to create a custom block to select an item from the answers list based on a specified range of items.
- With the teller sprite selected, click on the Make a Block button from the More Blocks palette. Name the block
say fortune in range:
. Then, add a number input and change the input name tostart range
. Next, add a label with the text and; finish the block by adding another number with the nameend range
. The following screenshot shows the resulting define block: - We want to use a similar set of blocks that we've already added to the if () then else block as we previously added to the when I receive (fortune) stack. The new expression will be say (item (pick random start range) to (end range) of (possible answers)) for (2) secs, as shown in the following screenshot:
- Let's put the custom block to use in the when I receive (fortune) script....