How to find first empty text box?

I don’t know how to deal with a certain logical problem. I’m creating a rebus game, the game window is: picture → empty letter fields for selected letters as a password to the rebus → 20 random letters among which are those allowing to write the correct password.

The game, after loading the window, randomizes for me using the extension “Choose::RandomString” random letters to 20 text boxes. See the screenshot, at the moment the player selects, for example, Letter1 and this one appears in the first field, the first letter of the password. But this is done wrong, because this way I have to describe each letter for each password field, and so on.

How do I make it so that the player can choose ANY letter from these 20, and the game adds it to the FIRST FREE field?

Later, I will work on making it possible to un-click a letter from the password field to return it to its place.

This will be a lot easier by using arrays. Now there are individual objects for everything. This dramatically increases the workload. There is a lot of programming intro/refresher educational material out there.

A simple method would be to use the Pick nearest object condition.

First add a hidden object and position it to the left of the 1st field, let’s say it’s name is “obj”.

The event would be something like this:

| the text field = ""                            |  Actions here
| pick the field nearest to obj.X() ; obj.Y()    |

I’m not sure if the fields in the screenshot are empty “” or there’s an underscore “_”
Just make sure that the condition check is equal to the text of the empty fields.

1 Like

@insein Thank you, this helped me a lot! Almost everything works, Im fighting with forcing letters back to their original places.

Fo example: If I selected the letter A in the second row, when I click on it in the password field, this letter returns to its place in the random letters ( and not to the first free, or nearest free)


One more thing is that the RandomLetters are Shuffling (to the same values) every time when the RandomLetter object is updated (fo example - when letter form PassObj is backing to RandomLetters obj).

There’s an issue with the top events. The shuffle array event and the event after it should be nested under the At beginning of scene. Follow the screenshot I sent you earlier in the other thread:


Random letters with password ones - #6 by insein


Also this event:

It should be a different object and not PassObj. Follow what I suggested earlier.


This requires object variables to set IDs for the RandomLetters and PassObj objects. Set IDs to the RandomLetters to be the same as the index of the “Letters” array. And when you click to choose a random letter, pass this ID to the PassObj. So that you’ll know which RandomLetters object to show/hide when returning a letter back.