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

#1 2012-02-11 13:12:36

19creeves
New Scratcher
Registered: 2012-02-11
Posts: 1

Ask a box questions

I need help making a game where you ask a box questions and it gives you awnsers, iI just dont know what scripts to use. Could someone give me the right scripts so I can do it? Id appreciate it if someone did.

Offline

 

#2 2012-02-11 15:04:22

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Ask a box questions

Well, that's gonna be hard to program. In fact, it'll be impossible to program. How are you gonna program answers to all the questions in the universe? And that's not taking spelling/grammar mistakes into account either.

Last edited by RedRocker227 (2012-02-11 15:04:37)


Why

Offline

 

#3 2012-02-11 16:27:05

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Ask a box questions

RedRocker227 wrote:

Well, that's gonna be hard to program. In fact, it'll be impossible to program. How are you gonna program answers to all the questions in the universe? And that's not taking spelling/grammar mistakes into account either.

Not impossible, and he didn't say every question.

Just use these blocks:  smile

(answer)

ask [] and wait
and probably a few variables.

Last edited by CheeseMunchy (2012-02-11 16:27:22)


6418,

Offline

 

#4 2012-02-11 16:32:31

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Ask a box questions

CheeseMunchy wrote:

RedRocker227 wrote:

Well, that's gonna be hard to program. In fact, it'll be impossible to program. How are you gonna program answers to all the questions in the universe? And that's not taking spelling/grammar mistakes into account either.

Not impossible, and he didn't say every question.

Oh, I see what he/she means now. I though they meant you ask it any question you like and it'll say the answer XD


Why

Offline

 

#5 2012-02-11 16:55:11

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Ask a box questions

RedRocker227 wrote:

CheeseMunchy wrote:

RedRocker227 wrote:

Well, that's gonna be hard to program. In fact, it'll be impossible to program. How are you gonna program answers to all the questions in the universe? And that's not taking spelling/grammar mistakes into account either.

Not impossible, and he didn't say every question.

Oh, I see what he/she means now. I though they meant you ask it any question you like and it'll say the answer XD

(asks bot): What is the precise mass of the universe measured in micrograms?
(responds) 999,999,999,999,999,999,999,999,999.999


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#6 2012-02-11 18:32:11

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: Ask a box questions

bobbybee wrote:

RedRocker227 wrote:

CheeseMunchy wrote:


Not impossible, and he didn't say every question.

Oh, I see what he/she means now. I though they meant you ask it any question you like and it'll say the answer XD

(asks bot): What is the precise mass of the universe measured in micrograms?
(responds) 999,999,999,999,999,999,999,999,999.999

XD

Cheese is right.

Offline

 

#7 2012-02-11 19:37:12

Haiming
Scratcher
Registered: 2011-08-20
Posts: 1000+

Re: Ask a box questions

Try making a list.

Offline

 

#8 2012-02-12 00:42:53

silvershine
Scratcher
Registered: 2010-11-21
Posts: 500+

Re: Ask a box questions

If there are a lot of questions you want the program to be able to respond to, the easiest and most efficient way to do this would be to create some lists that stores this information.

• Create a list named "questions" to record all the possible answers to questions that you decide on

when flag clicked
delete [all v] of [questions]
add [Can birds fly?]
• On another list create an answer for the question of the same number in the "question" list. For example, if item 1 in your question list is "can birds fly," then item 1 of the answer list would be "yes, they can fly"

when flag clicked
delete [all v] of [questions]
delete [all v] of [answers] //this is new!
add [Can birds fly?] to [questions v]
add [Yes, then can fly.] to [answers v] //this is new!
• Do that for all the questions you want the program to be able to answer. Next, add the scripts that allows the user to ask a question:

when flag clicked
delete [all v] of [questions]
delete [all v] of [answers]
add [Can birds fly?] to [questions v]
add [Yes, then can fly.] to [answers v]
forever //this is new!
ask [ask your question] and wait //this is new!
end
• This last part is a little advanced, but I'll do my best to explain it. First, take a look at what the scripts will look like:


when flag clicked
set [listNumber v] to [1] //this is new!
delete [all v] of [questions]
delete [all v] of [answers]
add [Can birds fly?] to [questions v]
add [Yes, then can fly.] to [answers v]
forever
ask [ask your question] and wait
set [listNumber v] to [1] //this is new!
repeat <length of [questions v]> //this is new!
if <<item (listNumber) of [questions v]>=<item (listNumber) of [answers v]>> //this is new!
say <item (listNumber) of [answers v]> for [3] secs //this is new!
else //this is new!
change [listNumber] by [1] //this is new!
end
end
say [sorry! I don't understand!] //this is new!
end
Basically, the more complicated scripts scan the list to see if what the user typed in matches anything on the list of known questions. If it finds something, it will answer with the list item with the same number as it's corresponding question.
The problem with this is that for a match to be found, the text that the user typed in must be exactly the same as what's in the list. That means that it's case sensitive, and punctuation sensitive.

Is that the answer you were looking for?

Last edited by silvershine (2012-02-12 00:55:36)

Offline

 

#9 2012-04-26 08:24:26

daves777
Scratcher
Registered: 2011-05-16
Posts: 1

Re: Ask a box questions

I'm trying to make a game when they ask you your name, and you type it in, it repeats it back to you. How do you do that?

Offline

 

#10 2012-04-26 08:32:34

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Ask a box questions

Hi daves777,
Next time you want to ask a question, make a new thread by clicking "Post New Topic" in the top-right corner of the list of topics.

Here's a script that repeats your name to you:

when gf clicked // start script
ask [What's your name?] and wait // ask for the name
say (answer) // reapeat it back
Enjoy!  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#11 2012-05-26 08:59:10

thewerewolffan
New Scratcher
Registered: 2012-05-26
Posts: 1

Re: Ask a box questions

i need help!! i want to know how to make if a countdown variable REACHES ZERO how do you make a cage full on the cat. what i want is the cage to fall on the cat so i would like the script.

Offline

 

#12 2012-05-27 00:02:43

silvershine
Scratcher
Registered: 2010-11-21
Posts: 500+

Re: Ask a box questions

thewerewolffan wrote:

i need help!! i want to know how to make if a countdown variable REACHES ZERO how do you make a cage full on the cat. what i want is the cage to fall on the cat so i would like the script.

Please go to the "Help with Scripts" section and click  "post new topic" in the upper righthand corner, and then state your question.  smile

Offline

 

Board footer