0

I am working on a game in Scratch based on Word puzzle. Player is given with set of alphabets on the screen and they have to make a word from it. I need to check first that the entered word is valid, for example: player entered 'wrok' but the valid word is 'Work'.

After the word is valid I want it to show on the Stage. Can anyone guide ?

I thought of using python script with Scratch, a variable can store the word entered by the player and it can be sent to python script and using python library enchant it can be checked. If the python returns True then it can be shown on the Stage.

I am not sure how to proceed or whether this procedure is correct.

Thank you

boisvert
  • 3,679
  • 2
  • 27
  • 53
shruti
  • 459
  • 6
  • 24

1 Answers1

1

Scratch has a very useful block for that, which is join. To make a word from letters chosen, make a Word variable. Make sure it is empty at the start, then join the letter to the word:

When [A] clicked
join (Word) (A)

As each letter is joined, the Word is built up.

To check if your word is valid, you compare it to a list of words that you find acceptable. If the list is short, you can do it in scratch - make a list and use something like

When (whatever event it is)
if < [list of acceptable words] contains (Word) >
    cat says the word
else
    cat says 'uh?'

If your list of acceptable words is very long, then another language is a better option. You need a file containing the words, and the program checks for the presence of your word in the file. The connection between Scratch and other languages depends on your platform (raspberry pi?).

boisvert
  • 3,679
  • 2
  • 27
  • 53
  • yep i am working on raspberry pi. Can you please guide how i can work with python script. Right now i have found the solution with the lists in Scratch but python script would be much better. – shruti Oct 01 '15 at 04:18
  • I've added python and pi tags so that the SO members who know more about this can answer. – boisvert Oct 01 '15 at 07:23