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 2
Download
5 KB


Goal:   Write to text boxes, change the Critter´s world.


Screenshot


Vocabulary:   startup, ct (cleartext), hidetext, showtext, insert, setbg, set, pos

Code
Shapes
Project Map

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

to conversation
question [Hi! What is your name?]
question [I don't have a name.   Please give me a name.]
text1, insert answer
showtext
question [Thanks! I like that name.   What color do you like best: red, yellow, orange, green, blue, or violet?]
changecolor
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



Notes

When a procedure is named startup, it will begin running as soon as you open the project.   Here, startup does four things:

  1. In this startup procedure,
    set "question "pos [-200 140] sets the pos ition of the question dialog box.   (The two numbers set the x and y coordinates of the top left corner of the box.)   You may choose different numbers to position the box.

  2. set "announce "pos [-200 140] sets the position of the announcement dialog box.   Again, you may choose different numbers.

  3. text1, ct tells the text box named text1 to ct ("clear text").   This erases everything in the text box.

  4. Hidetext hides the text box.

  5. Setbg means "set background color."   It needs a number as input.   0 is white.   This makes sure the background color is white.  

  6. The final command in the startup procedure is the name of another procedure called conversation.   Since this command is placed in the startup procedure, it will begin running automatically when the project is opened.

  7. In the conversation procedure, you may write your own questions.   But do respond to one answer like this:

    text1, insert answer inserts the answer into the text box named text1.   (Text can be inserted into the text box even when it is invisible.)

  8. Showtext makes the text box visible.  

  9. The last line of the conversation procedure calls the changecolor procedure.  

  10. Each line of the changecolor procedure is an if statement.

    if answer = "red [setbg "red] means, "If the text typed as an answer is the word red, then set the background color to red."

    The other if statements deal with other possible colors that might be typed as an answer.   When an if statement is true, the instructions in brackets will run.   If the statement is not true, the instructions in brackets will be ignored.   If your visitor types a word that is not among these colors, or uses a different spelling, then nothing will happen; the background color will not change.  




What If?
What happens if a user types a different color in the last question box, rather than one of the six listed colors?


Challenge
Can you set up a way for the user to start the conversation again, after it has finished?


On Your Own - Project Ideas
Create your own conversation which writes one or more answers to a text box or launches other actions.





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