Text input that only allows numbers?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Text input that only allows numbers?
In my game, each day, the player has to enter an integer. Any integer they put will give results, though some will give different results than others (like, if they put 0-50, a different thing happens than when they put in 51-100). I believe I know how to code the results, but I don't know how to do a specific text input that forces the player to only put integers (unless I manually do it, number by number). How should I do this?
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Text input that only allows numbers?
The standard input screen is very customiseable, as documentation tells us:
https://www.renpy.org/doc/html/input.html#text-input
In your case you want something like:
https://www.renpy.org/doc/html/input.html#text-input
In your case you want something like:
Code: Select all
$ renpy.input(allow="0123456789")
< < insert Rick Cook quote here > >
Re: Text input that only allows numbers?
Thanks! One more question though: How do I make the if statements relevant to the number the player inputted? Ex: If the player enters a number in between 100 and 249, the game jumps to a certain label.
Re: Text input that only allows numbers?
hi!
You can use conditional statements to do this! There's some good info here:
https://www.renpy.org/doc/html/quicksta ... statements
something like this might work for you:
You can use conditional statements to do this! There's some good info here:
https://www.renpy.org/doc/html/quicksta ... statements
something like this might work for you:
Code: Select all
$ number = renpy.input(allow="0123456789"
if number >= 100 and number <= 249:
jump label1
else:
jump label2
Re: Text input that only allows numbers?
Tip, Renpy uses Python condition statements, and Python can do this with conditions:
Code: Select all
if 100 <= number <= 249:
jump label1
Re: Text input that only allows numbers?
Thank you both for the help! It works now
Who is online
Users browsing this forum: Google [Bot]