I am doing a question and answer program with my students. The question I asked is, "What is your favorite sport?" We had 4 if loops for tennis, golf, swimming and basketball. For each loop, I had a comment such as, "Basketball rocks!" Since I couldn't possibly think of every sport, I put in an if-else loop for those situations, and the cat would say, "that sounds like a fun sport, too!".
I found the program did not work when I used the say block, but did work when I used the say for 2 sec block.
could someone explain to me why this is so? I would like to have an explanation for my students.
Thanks in advance1 Judy
Offline
The say block makes a sprite say something, then immediately (within the time span of one frame) runs the blocks below it. Also, it will say whatever you wrote until you make it say something else or make it say " "(equivalent to making it stop talking).
Are there any blocks underneath your say block, or are there any scripts that run after this one plays? Maybe a stop script block, a block making it say something else?
Also, do you have any means that we can see the script itself? That'd make finding the problem a lot easier.
Last edited by Kileymeister (2011-02-15 10:19:12)
Offline
[blocks]
<when green flag clicked>
ask "what is your favorite sport" and wait
<if>answer = swimming
<say[ Flipper ]for( 2 )secs>
<if>answer = tennis
<say[Love! ]for( 2 )secs>
<if>answer = golf
<say[ Fore! ]for(2 )secs>
<if>answer = basketball
<say[ Michael Jordan! ]for( 2 )secs>
<else>
<say[That sounds like a fun sport! ]for( 2 )secs>
[/blocks]
This works well. If I use the plain say block, it doesn't. I wanted to know why.
Thank you,
Judy
Offline
jpsrolls wrote:
[blocks]
<when green flag clicked>
ask "what is your favorite sport" and wait
<if>answer = swimming
<say[ Flipper ]for( 2 )secs>
<if>answer = tennis
<say[Love! ]for( 2 )secs>
<if>answer = golf
<say[ Fore! ]for(2 )secs>
<if>answer = basketball
<say[ Michael Jordan! ]for( 2 )secs>
<else>
<say[That sounds like a fun sport! ]for( 2 )secs>
[/blocks]
This works well. If I use the plain say block, it doesn't. I wanted to know why.
Thank you,
Judy
It doesn't say "That sounds like a fun sport!" after?
I would recommend this code: (untested )
when green flag clicked ask [What is your favorite sport?] and wait if <(answer) = [swimming]> say [swimming (or whatever you want.)] else if <(answer) = [tennis]> say [tennis] else if <(answer) = [golf]> say [golf] else if <(answer) = [basketball] say [basketball] else say [That sounds like a fun sport too!]
Last edited by scimonster (2011-02-15 13:34:27)
Offline
A way that would work a bit better, assuming you have a lot of sports you'd like to add, would be to create a list of all the sports you want it to recognize, and then a separate list with a corresponding response. Then you would use a script like this:
When green flag clicked Ask "What is your favorite sport?" and wait set [i] to 0 Repeat (length of [sports list]) change [i] by 1 if <item [i] of [sports list] = [answer]> say (item [i] of [responses]) end script end if end repeat say "That sounds like a fun sport!"
Offline