Getting keyboard input as a whole number

Hello everyone!
I’m trying to find a way to allow the player to input a number, and only an integer, between two values. I can get the text input to work, but I can’t find a way to accept only a number or to get a number out of a text string. Any ideas?

Thanks In advance and Happy Holidays!

Steve.

Here is an example I’ve shared that shows how to limit characters for the text entry object: [url][Fixed] Regex Gdevelop]
Open the scene variables list, you’ll see a big structure with lots of childs, each child represents an allowed character… just copy the logic in your code and in the variable add the numbers only, this way the user will be able to enter numbers only. To make the numbers work in a specific range you’ll have to add some extra events (you can convert a string to a number and then check if it’s in range) :neutral_face:

Thanks for the reply, I’ll give it a go.

Cheers,

Steve.

I decided to solve the problem visually, it turned out to be quite easy.

I just used the X position of a draggable sprite to feed into a global variable for the next scene. This provides a whole number between 0 and 777 and nothing else, which was what I wanted.
There are a few problems with this method, mainly you can only generate numbers within the size of the screen unless you use multipliers.
I’m not sure why, maybe someone with more experience can explain it, but I had to do -69 to the X position to get it to zero. The pointer starts at X 40 and the sprite “Pointer” position is set to 32, which should be 72?
I’ve attached my events for it, let me know what you think.