Conversations
In Scratch, two or more sprites can talk to one another, having a dialogue conversation. There are several scripting methods associated with this, each unique to the other. They mainly utilize the block or its timed counterpart for conversing.
Methods
For this entire article, assume the two sprites conversing are "Scratch Cat" and "Gobo".
Broadcast Method
The broadcast method is not always the most efficient way to make sprites communicate many messages, but short conversations can be easily made using broadcasts and no variables or lists. The following script would go into "Scratch Cat".
Then, inside the Gobo sprite:
The two sprites continuously broadcast back and forth to each other to say a message. However, when the conversation becomes long, multiple broadcasts are needed and the scripts can become unorganized.
Broadcast and Wait method
This method is slightly more efficient, because only one script is needed in the first sprite to talk.
Then, inside of Gobo:
Variable Method
The variable method uses a variable to trigger the other sprite to talk. After a sprite finishes speaking, it changes a variable by "1", in which the other sprite recognizes and then begins speaking. The following script would go into "Scratch Cat".
And for the "Gobo" sprite:
The script can keep cycling continuously. The script can become very long from a long conversation, but it does not use multiple of any broadcasts. The variable method is often best for unordered conversations, in which there are multiple sprites not speaking to one another in a patterned fashion.
List Method
The list method uses the same amount of scripting no matter how long the conversation is. It is a great method to reduce large scripts and a project's file size. The list method uses two scripts, one of "Scratch Cat's" messages and one of "Gobo's". The first sprite says a message, triggers the second sprite to speak, and then the cycle continues, with a variable being changed after both have fully spoken, to signal the next message from the lists. The lists are used to simply store the text which each sprite will speak, and is ordered within. The following script goes into "Scratch Cat"
And for "Gobo":