[SOLVED] Ask for a random key press

Okay, so a letter will show up on the screen (I got that covered already). And I want it so that you have to press the key that is corresponding to the letter shown.
It has something to do with the Key Press condition, but I can’t make it work because it’s always asking for a valid key.

Edited this to make it clearer.

Hello @Lenicon ,
I suggest you to watch this video: How to Generate random strings in Gdevelop From Given Strings | Choose Extension - YouTube
Instead of fruits you can list all characters.

Bye,
J

image
Nope, doesn’t seem to work. Numbers, strings, and not numbers nor strings, all are not working.

You can do like that I guess.
Have a variable string with all the letters wanted, and randomly pick a character in the string

1 Like

Did you install the extension ?

Hold on, how does this make the key press do it’s thing?
Okay, so a letter will show up on the screen (I got that covered already). And I want it so that you have to press the key that is corresponding to the letter shown.
For some reason I can’t put variables and stuff in the Key Press condition, it’s always asking for a key.

I think we were not on the same page, but thanks for helping!

I think it’s not the key pressed condition you need then, cause it doesn’t write the character anywhere, and you won’t be able to compare it with the character on the screen. You have to set a textentry object on your scene that can detect what character the player is typing. Then you can compare the textentry.string with the wanted-character.

1 Like

ohhhh, I didn’t see there was a textentry! Thanks for the help!

1 Like

And @Lenicon, yes you can :

This sets the background to red when the key pressed matches the letter on the screen.


Note, you need to use the Key pressed (text expression) or Key released (text expression) condition :

image

2 Likes

Oh thanks! I didn’t know that was possible!