Ask here your questions to get help using GDevelop.
By Steve
#69112 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.
User avatar
By Lizard-13
#69116 Here is an example I've shared that shows how to limit characters for the text entry object: http://forum.compilgames.net/viewtopic.php?f=19&t=9730#p65375
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) :|
By Steve
#69221 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.
Attachments
ScoreSlider.png
ScoreSlider.png (100.59 KiB) Viewed 95 times