In this video,
you'll add another input that will change the emotion
the sprite is feeling.
Right click the define speak block and select Edit.
The costume name is also a string,
so add another sting input.
Call it emotion and click okay.
Another box appears at the right end
of each of the speak blocks.
This is where you enter the emotion
that will show at the end of the sentence.
To program the sprite to switch to the costume
that reflects the right emotion for your conversation,
type in the exact name of a costume.
The starter project contains a note listing
the costume names.
Or, you can see them by clicking the Costumes tab.
Each emotion displayed will reflect the tone
of the dialogue Malik says.
You will choose the emotions that most closely match
the lines of dialog in your project.
Next, update the speak block's definition so it can change
the emotion costumes as well as what the sprite says.
Drive the emotion parameter from the definition
into the switch costume block,
where it shows the sprite's emotion.
Click the flag to test the code.
The sprite moves its mouth while it says the first line.
Switches to happy, then says the second line
and switches to disgusted.
But, the sprite switches costumes so quickly
it's hard to see them.
Place a wait block after the first speak block.
Click the flag to test whether you can see each
of the reactions.
In this case, Malik smiles before looking disgusted.
Your project is already doing a lot of different things
and the code is still short and simple, thanks to functions.
Right now, only Malik talks, so this conversation
is pretty one-sided.
Program the the other sprite, Isabel,
to talk and turn the animation into a dialogue.
Most of the programming you will use to make Isabel talk
is the same you used to make Malik talk.
So copy the three code stacks from the Malik talk sprite
into the Isabel talk sprite.
Click the Isabel talk sprite,
then right click the script's area.
Select Clean up, to automatically order the code stacks.
Change the code slightly, for the Isabel talk sprite
to make the conversation work correctly.
For example, the speak function in Isabel talk,
should not make Malik's mouth move
by broadcasting Malik talking.
Name the broadcast block something that makes sense,
like Isabel Talking.
Next, click the drop down on the when I receive block,
and select Isabel Talking.
Finally, change what Isabel says and what emotions
are shown in the speak blocks.
In this example, Isabel first says,
"Peanut butter and jelly sandwiches!" with a happy face.
Then, "Why don't you like them?" with a sad face.
Oh no, Isabel and Malik talk at the same time.
You'll fix this in the next video.
Now it's your turn.
Add a string input called emotion.
Update the speak blocks to input an emotion.
Copy the three block stacks
from Malik Talk to Isabel Talk.
Change the values in the broadcast for Isabel Talk.
Sign in to save your project and track your progress.