How to get an object (a cat) to say something based on a random selection of a set of phrases


I am new to coding and CoSpaces but I wanted to recreate a play on a magic 8 ball - the initial ideas is that the user will engage with the merge cube by clicking a button), however later if possible it would be good to display this text if the cube is shaken (though I am unsure if this an option!)

So I have created a merge cube environment with on the front I have a button which the user can click. On the top of the cube, I have a cat. When the button is clicked, the cat will say one of 20 responses randomly selected from a set list of responses.

The idea is a slightly edited version of this scratch exercise (see image). However, since CoBlock is a bit different from Scratch I cant seem to figure how to set the responses and for the cat to say them.

Any suggestions?

Hi @Kate_M,

You could create a list of phrases, then generate a random number and use say CoBlock to say a phrase from the list. Please, refer to this tutorial to learn how to use lists in CoSpaces.

Hope that helps!

Hi @Kate_M,

You can create a list of phrases using some of the List CoBlocks (under Data > Lists). First create an empty list, then add some Text values (under Data > Values) to it.

From there, it should be plain sailing, as very similar CoBlocks exist for most of your Scratch code.

Let me know how you go. I could create the whole thing for you, but I don’t want to spoil your fun (and learning)!

Best of luck,
Geoff @ TechLeap