Scratch – Conversation Program Basic 6 Basic Technology Lesson Note

Download Lesson Note
Lesson Notes

Topic: Scratch – Conversation Program

Learning Objectives

By the end of the lesson, pupils should be able to:

  1. 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):

  1. say [text] for (2) seconds – Sprite says something briefly
  2. say [text] – Sprite says something until next action
  3. think [text] for (2) seconds – Shows thought bubble
  4. think [text] – Continuous thought bubble

From Events Category (Yellow):

  1. when flag clicked – Starts program
  2. when this sprite clicked – Starts when sprite clicked
  3. when I receive [message] – Responds to broadcast

From Control Category (Orange):

  1. wait (seconds) – Pauses before next action
  2. broadcast [message] – Sends signal to other sprites
  3. broadcast [message] and wait – Sends signal and waits for response

PROJECT 1: SIMPLE TWO-PERSON CONVERSATION

Setup:

  1. Keep default Scratch Cat (rename to “Tom”)
  2. Add another sprite (choose from library, e.g., “Girl” – rename to “Sarah”)
  3. 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:

  1. 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
  1. Natural Flow:
  • Make conversations realistic
  • Characters should respond appropriately
  • Use greetings and farewells
  • Stay on topic
  1. Visual Cues:
  • Position sprites to face each other
  • Use costumes to show emotions
  • Add movements for engagement
  • Use appropriate backgrounds
  1. Organization:
  • Use broadcasts for better control
  • Name broadcasts clearly (e.g., “tom_done” not “message1”)
  • Comment your code
  • Test frequently
  1. Content:
  • Keep messages appropriate and friendly
  • Make it educational if possible
  • Add humor when suitable
  • Create interesting scenarios

Practice Projects:

  1. School Conversation:
  • Two students discussing homework
  • Topics: subjects, assignments, test preparation
  1. Shopping Dialogue:
  • Customer and shopkeeper
  • Topics: asking for items, prices, thanking
  1. Sports Discussion:
  • Friends talking about favorite sports
  • Topics: teams, games, skills
  1. Family Chat:
  • Parent and child or siblings
  • Topics: daily activities, plans, chores
  1. Interview Format:
  • Interviewer and celebrity/expert
  • Topics: career, interests, advice

Debugging Conversation Programs:

Common Problems:

  1. Overlapping Speech:
  • Solution: Use broadcasts or proper wait times
  1. Wrong Order:
  • Solution: Check broadcast names and timing
  1. Too Fast/Too Slow:
  • Solution: Adjust wait times and display duration
  1. Sprite Not Responding:
  • Solution: Check event blocks and broadcast names
  1. Message Cut Off:
  • Solution: Increase display time

Advanced Features:

  1. 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

 

  1. 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]

Lesson Notes for Other Classes