I'm trying to create a simple form on one of my menu screens that consists of a text field and a button... players can input a value and press submit. On submit, the value would go into a variable for me to use.
I'm having trouble getting this to work, and I was wondering if there's a specific feature of ren'py I should be using for this. Anyone have any examples? Thanks.
Simple Form
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.
-
- Newbie
- Posts: 7
- Joined: Tue Nov 01, 2016 12:31 pm
- Contact:
- DannyGMaster
- Regular
- Posts: 113
- Joined: Fri Sep 02, 2016 11:07 am
- Contact:
Re: Simple Form
The standard way Ren'py receives user input is with the renpy.input function, when you call it you assign the input to a variable for later use. Here's an example:
When you call this function, it displays a prompt where the user can enter text. This is stored in the new_name variable, and then you can process it however you like. You could make a similar function and call it from your form screen, or you can modify the default input screen (in your screens.rpy file) to make it look like a form, that's what I'll be doing.
http://www.renpy.org/doc/html/screen_special.html#input
Code: Select all
init python:
def input_name(character):
new_name = renpy.input("What is your name?", length=9)
new_name = new_name.strip()
if not new_name:
pass
else:
character.name = new_name
define e = Character("Eileen")
label start:
$ input_name(e) #Call the function
e "I'm [e.name]."
http://www.renpy.org/doc/html/screen_special.html#input
The silent voice within one's heart whispers the most profound wisdom.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]