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

#1 2009-06-10 21:12:38

pross67
Scratcher
Registered: 2007-05-26
Posts: 18

Question about the "answer" block

Hi.

Is there a way to check the contents of the answer for a word? Something like the "contains" block for a list.

So if the user types "walk across the street" as an answer, I have a script that says:

if [answer] contains "walk" or "street" then...

I guess you can see I'm trying to make a text adventure game  smile

Offline

 

#2 2009-06-10 21:40:26

fruit
Scratcher
Registered: 2009-04-24
Posts: 1000+

Re: Question about the "answer" block

Add all of them to a list and use the if item (any) of list =


@savi3000 | hcsmp.com

Offline

 

#3 2009-06-10 23:13:42

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Question about the "answer" block

This would be a nice block. "Contains word or phrase" That would be awesome!

Offline

 

#4 2009-06-11 07:15:03

bhz
Scratcher
Registered: 2008-07-06
Posts: 100+

Re: Question about the "answer" block

pross67 wrote:

Hi.

Is there a way to check the contents of the answer for a word? Something like the "contains" block for a list.

So if the user types "walk across the street" as an answer, I have a script that says:

if [answer] contains "walk" or "street" then...

I guess you can see I'm trying to make a text adventure game  smile

I made a project with comments...
http://scratch.mit.edu/projects/bhz/565724

Offline

 

#5 2009-06-11 09:29:03

pross67
Scratcher
Registered: 2007-05-26
Posts: 18

Re: Question about the "answer" block

Very nice proof of concept, bhz. Just too many scripts to be useful in even a small text adventure game.

Scratch team, how about a block to check for a string in the answer block? My god, that would be cool.

Last edited by pross67 (2009-06-11 09:29:32)

Offline

 

#6 2009-06-11 11:22:00

bhz
Scratcher
Registered: 2008-07-06
Posts: 100+

Re: Question about the "answer" block

pross67 wrote:

Very nice proof of concept, bhz. Just too many scripts to be useful in even a small text adventure game.

Scratch team, how about a block to check for a string in the answer block? My god, that would be cool.

You can always do:
if < letter ( n + 1 ) of ( answer ) = a > and < letter ( n + 2 ) of ( answer ) = l > ...
But I have top agree...that WILL be cool

Offline

 

#7 2009-06-11 14:58:55

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Question about the "answer" block

theres one in operators:

If<(answer) contains [samson]>
Say(noooooo)
Else
Say(yessssss)


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

Board footer