Scratch – Conversation Program Basic 6 Basic Technology Lesson Note
Download Lesson NoteTopic: Scratch – Conversation Program
Learning Objectives
By the end of the lesson, pupils should be able to:
- Apply Scratch programming to execute a string of conversation between two friends
Content
Creating Conversations in Scratch
Conversations in Scratch involve multiple sprites talking to each other in sequence, creating dialogue.
Key Blocks for Conversations:
From Looks Category (Purple):
- say [text] for (2) seconds – Sprite says something briefly
- say [text] – Sprite says something until next action
- think [text] for (2) seconds – Shows thought bubble
- think [text] – Continuous thought bubble
From Events Category (Yellow):
- when flag clicked – Starts program
- when this sprite clicked – Starts when sprite clicked
- when I receive [message] – Responds to broadcast
From Control Category (Orange):
- wait (seconds) – Pauses before next action
- broadcast [message] – Sends signal to other sprites
- broadcast [message] and wait – Sends signal and waits for response
PROJECT 1: SIMPLE TWO-PERSON CONVERSATION
Setup:
- Keep default Scratch Cat (rename to “Tom”)
- Add another sprite (choose from library, e.g., “Girl” – rename to “Sarah”)
- Position sprites facing each other
Tom’s Script:
when flag clicked
say [Hi Sarah! How are you today?] for (3) seconds
wait (3) seconds
say [That’s great! What did you do today?] for (3) seconds
wait (3) seconds
say [Wow! That sounds like fun!] for (3) seconds
wait (2) seconds
say [See you tomorrow!] for (2) seconds
Sarah’s Script:
when flag clicked
wait (3) seconds
say [Hi Tom! I’m doing great, thanks!] for (3) seconds
wait (3) seconds
say [I went to the park and played football.] for (3) seconds
wait (3) seconds
say [Yes, it was! Bye Tom!] for (2) seconds
How it Works:
- Both scripts start when flag clicked
- Tom speaks first
- Sarah waits 3 seconds before responding
- They alternate speaking with proper timing
PROJECT 2: CONVERSATION USING BROADCAST
This method is more reliable for timing conversations.
Tom’s Script:
when flag clicked
say [Hello! What’s your name?] for (3) seconds
broadcast [name question v]
when I receive [name given v]
say [Nice to meet you, Sarah!] for (3) seconds
broadcast [age question v]
when I receive [age given v]
say [Cool! I’m 12 years old too.] for (3) seconds
broadcast [hobby question v]
when I receive [hobby given v]
say [That’s awesome! I love reading too!] for (3) seconds
Sarah’s Script:
when I receive [name question v]
say [My name is Sarah. What’s yours?] for (3) seconds
broadcast [name given v]
when I receive [age question v]
say [I’m Tom. How old are you?] for (2) seconds
wait (3) seconds
say [I’m 12 years old.] for (3) seconds
broadcast [age given v]
when I receive [hobby question v]
say [What do you like to do?] for (2) seconds
wait (3) seconds
say [I enjoy reading books.] for (3) seconds
broadcast [hobby given v]
Advantages of Broadcast Method:
- More reliable timing
- Better control
- Easier to modify
- Less risk of overlap
- Can add more sprites easily
PROJECT 3: MULTI-CHARACTER CONVERSATION
Setup:
- 3 sprites: Tom, Sarah, and David
Tom’s Script:
when flag clicked
say [Hey everyone! Want to play a game?] for (3) seconds
broadcast [tom done v]
when I receive [david done v]
say [Great! Let’s play football!] for (3) seconds
broadcast [tom done2 v]
Sarah’s Script:
when I receive [tom done v]
say [Sure, Tom! What game?] for (3) seconds
broadcast [sarah done v]
when I receive [tom done2 v]
say [Sounds fun! I’m in!] for (3) seconds
David’s Script:
when I receive [sarah done v]
say [Count me in too!] for (3) seconds
broadcast [david done v]
PROJECT 4: QUESTION AND ANSWER CONVERSATION
Interactive conversation where sprite responds to user input.
Tom’s Script:
when flag clicked
say [Hello! I’m Tom.] for (2) seconds
ask [What’s your name?] and wait
set [user_name v] to (answer)
say (join [Nice to meet you, ] (user_name)) for (3) seconds
ask [How old are you?] and wait
set [user_age v] to (answer)
say (join [Wow! ] (join (user_age) [ is a great age!])) for (3) seconds
ask [What’s your favorite subject?] and wait
set [favorite_subject v] to (answer)
say (join [I like ] (join (favorite_subject) [ too!])) for (3) seconds
say [Thanks for chatting with me!] for (2) seconds
PROJECT 5: EMOTIONAL CONVERSATION WITH COSTUME CHANGES
Setup:
- Use sprite with multiple costumes showing different emotions
- Change costumes during conversation
Tom’s Script:
when flag clicked
switch costume to [happy v]
say [I’m so excited! Today is my birthday!] for (3) seconds
broadcast [birthday v]
when I receive [sympathy v]
switch costume to [sad v]
say [Oh no! That’s okay though.] for (3) seconds
broadcast [cheer up v]
when I receive [encouragement v]
switch costume to [happy v]
say [You’re right! Let’s have fun anyway!] for (3) seconds
Sarah’s Script:
when I receive [birthday v]
say [Happy Birthday, Tom!] for (2) seconds
ask [Are you having a party?] and wait
broadcast [sympathy v]
when I receive [cheer up v]
say [Don’t worry! We can celebrate together!] for (3) seconds
broadcast [encouragement v]
PROJECT 6: STORYTELLING CONVERSATION
Setup:
- Two characters telling a story together
Narrator’s Script:
when flag clicked
say [Once upon a time…] for (3) seconds
broadcast [scene 1 v]
when I receive [scene 2 start v]
say [And then…] for (2) seconds
broadcast [scene 2 v]
when I receive [ending start v]
say [And they lived happily ever after!] for (3) seconds
Character 1’s Script:
when I receive [scene 1 v]
say [There was a brave knight named Sir Tom.] for (3) seconds
broadcast [scene 1 done v]
when I receive [scene 2 v]
say [He fought a fierce dragon!] for (3) seconds
broadcast [scene 2 done v]
Character 2’s Script:
when I receive [scene 1 done v]
say [He lived in a grand castle.] for (3) seconds
broadcast [scene 2 start v]
when I receive [scene 2 done v]
say [And he saved the princess!] for (3) seconds
broadcast [ending start v]
Adding Movement and Animation:
Moving While Talking:
when flag clicked
go to x: (-200) y: (0)
say [I’m walking to school!] for (2) seconds
glide (3) secs to x: (200) y: (0)
say [I made it!] for (2) seconds
Turning to Face Each Other:
when flag clicked
point towards [Sarah v]
say [Hello Sarah!] for (2) seconds
Tips for Creating Good Conversations:
- Timing:
- Allow enough time to read each message
- Use appropriate wait times
- Match speaking time to message length
- General rule: 1 second per 5-7 words
- Natural Flow:
- Make conversations realistic
- Characters should respond appropriately
- Use greetings and farewells
- Stay on topic
- Visual Cues:
- Position sprites to face each other
- Use costumes to show emotions
- Add movements for engagement
- Use appropriate backgrounds
- Organization:
- Use broadcasts for better control
- Name broadcasts clearly (e.g., “tom_done” not “message1”)
- Comment your code
- Test frequently
- Content:
- Keep messages appropriate and friendly
- Make it educational if possible
- Add humor when suitable
- Create interesting scenarios
Practice Projects:
- School Conversation:
- Two students discussing homework
- Topics: subjects, assignments, test preparation
- Shopping Dialogue:
- Customer and shopkeeper
- Topics: asking for items, prices, thanking
- Sports Discussion:
- Friends talking about favorite sports
- Topics: teams, games, skills
- Family Chat:
- Parent and child or siblings
- Topics: daily activities, plans, chores
- Interview Format:
- Interviewer and celebrity/expert
- Topics: career, interests, advice
Debugging Conversation Programs:
Common Problems:
- Overlapping Speech:
- Solution: Use broadcasts or proper wait times
- Wrong Order:
- Solution: Check broadcast names and timing
- Too Fast/Too Slow:
- Solution: Adjust wait times and display duration
- Sprite Not Responding:
- Solution: Check event blocks and broadcast names
- Message Cut Off:
- Solution: Increase display time
Advanced Features:
- Random Responses:
when I receive [question v]
set [random_num v] to (pick random (1) to (3))
if <(random_num) = (1)> then
  say [Yes, I agree!] for (2) seconds
end
if <(random_num) = (2)> then
  say [Hmm, maybe…] for (2) seconds
end
if <(random_num) = (3)> then
  say [I’m not sure.] for (2) seconds
end
- User Choice in Conversation:
when flag clicked
say [Hi! Want to hear a joke or a story?] for (3) seconds
ask [Type ‘joke’ or ‘story’] and wait
if <(answer) = [joke]> then
  broadcast [tell joke v]
else
  if <(answer) = [story]> then
    broadcast [tell story v]