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

#1 2007-12-05 00:01:44

Ferret321
Scratcher
Registered: 2007-06-09
Posts: 6

Inserting Text?

Hey, I'm trying to make a riddle game right now. I really want to have the person playing it have to type the answer in inside a little box. Then, I want to run something saying something like:

If Variable= "The Butler"
Then
Print "Correct"

But, in Scratch Language. Is this possible?

Thanks ahead of time.

Offline

 

#2 2007-12-05 02:17:29

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Inserting Text?

Hi Ferret321,

currently Scratch does not support Arrays or Strings as variables. There are several ways, however, people have come up with to deal with this in Scratch:

1. Creating many variables (or many sprites)

Some projects define their own batch of variables to represent an array of of a fixed, limited size and then 'translate' character input (obtained from the 'when key _ pressed' event hat) to numbers. This method only works for very short texts and is extremely complicated to implement.

2. Storing / reading arrayed data as colored pen marks

There are some projects by some smart people which bypass this limitation by storing data arrays as colored pen marks in the Scratch stage and reading them back in using a sprite's color sensing abilities. This method enables longer texts to be stored and retained, but it is pretty advanced and probably even harder to accomplish if you're just starting out with Scratch. Also, comparing two strings would be an even more complicated procedure (one which I can't remember ever having seen in a Scratch project).

3. Mulitple choice

Another way to do a riddle game is to do it as a multiple choice quiz. For each question you could assign an 'answer' variable (a number indicating the correct answer to that question), and then have your project display several answers in several sprites and check for the correct user reaction (e.g. a click on the 'right' sprite).

I definitely would encourage you to try this third method, because you will be actually creating your riddle quiz instead of spending all the time kludging around with low level stuff.

Does that answer your question?


Jens Mönig

Offline

 

#3 2007-12-05 19:34:06

Ferret321
Scratcher
Registered: 2007-06-09
Posts: 6

Re: Inserting Text?

Yeah, that really does help. Thanks a lot.
Unfortunately, I'm not advanced in any programming language, so the more complicated stuff will phase me until i learn more.

So, I guess I'll try the third option. Thanks.

Offline

 

Board footer