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

#1 2010-08-01 11:41:21

dorkcat
Scratcher
Registered: 2009-09-10
Posts: 1

typing letters in a specific order

I want to have a student type a word such as "water".  A visual model of the letter to be typed is shown on the stage (i.e., an A is shown on the stage if I want them to type an A).
I can code things so that if the student doesn't make any errors typing the letters in the right order, things go well. But what if s/he types the "t" or "e" before the "A". I can code that the "w" has to be before the A, but simply cannot figure out how to prevent errors.

Basically I want to say, "if W hasn't been typed, then don't allow the A, T, E, R sprites to run their scripts until it has." and "If W and A haven't been typed, don't allow the T,E,R sprites to run their scripts until they have; etc.
If you need to see the project to answer, I can share it.

Offline

 

#2 2010-08-01 13:56:34

m71134
Scratcher
Registered: 2010-03-03
Posts: 1000+

Re: typing letters in a specific order

Hmm...I might be able to help if I can see the project.

Offline

 

#3 2010-08-01 15:49:11

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: typing letters in a specific order

Use a variable named Count that starts out at 1. Store "water" as the variable Word (or a list item if you plan to use multiple words) and whenever a letter is entered, compare the entered letter using (green operator block) item <count> of Word. If it matches, increase Count by 1 and go to the next letter.

If that sounds crazy just say so and I'll whip this up in a working project that you can tweak as needed.

Last edited by Locomule (2010-08-01 15:50:40)


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#4 2010-08-01 16:07:23

06dknibbs
Scratcher
Registered: 2008-01-29
Posts: 1000+

Re: typing letters in a specific order

You could try something like:

[blocks]

<when green flag clicked>
<wait until><key[ W ]pressed?>

(Anything else goes here etc: )

<wait until><key[ A ]pressed?>

(Anything else goes here etc: )

<wait until><key[ T ]pressed?>

(Anything else goes here etc: )

<wait until><key[ E ]pressed?>

(Anything else goes here etc: )

<wait until><key[ R ]pressed?>

(And again, anything else goes here etc: )
[/blocks]

That way, only the letter that needs to be pressed should work  smile


http://i404.photobucket.com/albums/pp129/06dknibbs/Untitled-3-6.jpg

Offline

 

#5 2010-08-01 16:12:40

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: typing letters in a specific order

06dknibbs wrote:

You could try something like:

[blocks]

<when green flag clicked>
<wait until><key[ W ]pressed?>

(Anything else goes here etc: )

<wait until><key[ A ]pressed?>

(Anything else goes here etc: )

<wait until><key[ T ]pressed?>

(Anything else goes here etc: )

<wait until><key[ E ]pressed?>

(Anything else goes here etc: )

<wait until><key[ R ]pressed?>

(And again, anything else goes here etc: )
[/blocks]

That way, only the letter that needs to be pressed should work  smile

Yes. This should work, except if two words starts with the same thing, it might glitch up.

Offline

 

#6 2010-08-01 17:38:44

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: typing letters in a specific order

My project Color Search Engine is similar to what you want. See if you can adapt its scripts.


http://i48.tinypic.com/2z5pqad.png

Offline

 

#7 2010-08-01 21:56:07

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: typing letters in a specific order

06dknibbs wrote:

You could try something like:

[blocks]

<when green flag clicked>
<wait until><key[ W ]pressed?>

(Anything else goes here etc: )

<wait until><key[ A ]pressed?>

(Anything else goes here etc: )

<wait until><key[ T ]pressed?>

(Anything else goes here etc: )

<wait until><key[ E ]pressed?>

(Anything else goes here etc: )

<wait until><key[ R ]pressed?>

(And again, anything else goes here etc: )
[/blocks]

That way, only the letter that needs to be pressed should work  smile

Of course, you could just mash buttons with this. (Not to put down your suggestion, I'm just saying it could defeat the purpose.) But I don't see a way to fix that without manually adding in <and not(key _ pressed)> for every, single, other, key.  hmm

Last edited by Harakou (2010-08-01 21:56:53)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer