This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-29 18:06:26

johndrumcrazy
New Scratcher
Registered: 2012-04-29
Posts: 2

Asking yes and no

New to this
A sprite asks would you like me to XXXXX
How do I use the answer.
If yes do one thing
If no do another

Offline

 

#2 2012-04-29 18:17:53

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Re: Asking yes and no

Here's an example:

When gf clicked
ask [Do you like the color blue?] and wait
if <(answer) = [yes] >
 say [I like blue, too!] for (2) secs
end
if <(answer) = [no] >
  say [well, that's too bad...] for (3) secs
end
if < not < <(answer) = [no] > or <(answer) = [yes] > > >
  broadcast [ask color question again v] //this is if they don't answer right
end

When I receive [ask color question again v] 
ask [Do you like the color blue?] and wait
if <(answer) = [yes] >
 say [I like blue, too!] for (2) secs
end
if <(answer) = [no] >
  say [well, that's too bad...] for (3) secs
end
if < not < <(answer) = [no] > or <(answer) = [yes] > > >
  broadcast [ask color question again v] 
end
You can do this for any yes or no question.

Last edited by AgentRoop (2012-04-29 18:19:42)


La La
I wrote an album.

Offline

 

#3 2012-04-29 18:31:41

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Asking yes and no

AgentRoop wrote:

Here's an example:

When gf clicked
ask [Do you like the color blue?] and wait
if <(answer) = [yes] >
 say [I like blue, too!] for (2) secs
end
if <(answer) = [no] >
  say [well, that's too bad...] for (3) secs
end
if < not < <(answer) = [no] > or <(answer) = [yes] > > >
  broadcast [ask color question again v] //this is if they don't answer right
end

When I receive [ask color question again v] 
ask [Do you like the color blue?] and wait
if <(answer) = [yes] >
 say [I like blue, too!] for (2) secs
end
if <(answer) = [no] >
  say [well, that's too bad...] for (3) secs
end
if < not < <(answer) = [no] > or <(answer) = [yes] > > >
  broadcast [ask color question again v] 
end
You can do this for any yes or no question.

Or you could do this:

when gf clicked
broadcast [ask color question again v]

When I receive [ask color question again v] 
ask [Do you like the color blue?] and wait
if <(answer) = [yes] >
 say [I like blue, too!] for (2) secs
end
if <(answer) = [no] >
  say [well, that's too bad...] for (3) secs
end
if < not < <(answer) = [no] > or <(answer) = [yes] > > >
  broadcast [ask color question again v] 
end


Get ready for domination of:  tongue

Offline

 

#4 2012-04-30 04:53:22

johndrumcrazy
New Scratcher
Registered: 2012-04-29
Posts: 2

Re: Asking yes and no

Thanks guys. got me started

Offline

 

#5 2012-04-30 04:56:53

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Asking yes and no

You can also change the broadcast into a variable. How I wish the booleans would not appear as reporters.  lol

Last edited by jontmy00 (2012-04-30 04:58:09)


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#6 2012-04-30 12:54:26

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Asking yes and no

Here it is in a single script:

when gf clicked
ask [Do you like blue?] and wait
if <not <<(answer) = [yes]> or <(answer) = [no]>>>
  repeat until <<(answer) = [yes]> or <(answer) = [no]>>
    ask [Sorry, what did you say?] and wait
  end
end
if <(answer) = [yes]>
  say [Me too!] for (3) secs
end
if <(answer) = [no]>
  say [Well, I do.] for (3) secs
end

Last edited by SciTecCf (2012-04-30 12:57:31)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#7 2012-04-30 17:37:51

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Re: Asking yes and no

SciTecCf wrote:

Here it is in a single script:

when gf clicked
ask [Do you like blue?] and wait
if <not <<(answer) = [yes]> or <(answer) = [no]>>>
  repeat until <<(answer) = [yes]> or <(answer) = [no]>>
    ask [Sorry, what did you say?] and wait
  end
end
if <(answer) = [yes]>
  say [Me too!] for (3) secs
end
if <(answer) = [no]>
  say [Well, I do.] for (3) secs
end

That's good, too.


La La
I wrote an album.

Offline

 

Board footer