Home
Project Folders
Teacher Resources
Student Resources
En ESPAÑOL
How Do I?
Vocabulary
MWForum
Site Map
Search
Our Team

critter chat 1 2 3 4 5 6 7
Critter Chat 4
Download
11 KB


Goal:   Compose customized sentences.


Screenshot


Vocabulary:   empty?, se (sentence), stopall

Code
Shapes
Project Map

to startup
set "question "pos [-200 140]
set "announce "pos [-200 140]
text1, ct hidetext
setbg 0
t1, setsh "critter
conversation
end

to conversation
question [Hi! Do you want to talk? (Type YES or NO.)]
if answer = "no [stop]
if empty? answer [stop]
question [What is your name?]
if empty? answer [stop]
text1, ct insert "Hi, insert char 32 insert answer insert "! showtext
question (se answer [, I don't have a name.   Please give me a name.] )
if empty? answer [stop]
text1, ct insert "I'm insert char 32 insert answer insert "!
question [What color do you like best: red, yellow, orange, green, blue, or violet?]
if empty? answer [stop]
changecolor
question (se [ I like] answer [, too.   Which sport do you like best: football, baseball, basketball, or soccer?] )
insist
announce (se [I like] answer [best, too! Watch me turn into a ball!] )
setsh answer
text1, ct insert [I'm a] insert char 32 insert answer if answer = "soccer [insert "ball] insert "!
end

to changecolor
if answer = "red [setbg "red]
if answer = "yellow [setbg "yellow]
if answer = "orange [setbg "orange]
if answer = "green [setbg "green]
if answer = "blue [setbg "blue]
if answer = "violet [setbg "violet]
end

to insist
if member? answer [basketball baseball football soccer] [stop]
if empty? answer [stopall]
question [Which sport do you like best: football, baseball, basketball, or soccer? (Spell carefully!)]
insist
end

to Let's_talk_again!
startup
end



Notes

We need a way to stop the questions if the user clicks cancel or gives no answer.  

  1. After every question in the conversation procedure, use the command
    if empty? answer [stop]
    to check for an answer and stop the procedure if the answer box is empty.

  2. Use se (sentence) to include an answer in the next question or in an announcement.   Put parentheses ( ) around se, the answer, and everything else that you want to include.   The parentheses allow the se command to take more than two inputs.

  3. In the insist procedure, if the user clicks cancel or gives no answer, we do not just want to stop the insist procedure, we also want to stop the conversation procedure.   We need to stop everything.   For this, we need stopall in this command:
    if empty? answer [stopall]




What If?
What happens if you change this line: if empty? answer [stopall] to this:

if empty? answer [announce "Good-bye! stopall]


Challenge
Can you write your own questions which include the user's answers in them?
If the user doesn't answer a question, can you make the critter say or do something funny before stopping the conversation?


On Your Own - Project Ideas
Can you set up a project in which a user clicks on different turtles (wearing shapes, such as animals) to launch a question about each shape and receive feedback on the answer?





© copyright 2001 - 2016  OpenWorld Learning.   All rights reserved.