Simple Form

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
JustinHanks
Newbie
Posts: 7
Joined: Tue Nov 01, 2016 12:31 pm
Contact:

Simple Form

#1 Post by JustinHanks »

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.

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Simple Form

#2 Post by DannyGMaster »

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:

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]."
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
The silent voice within one's heart whispers the most profound wisdom.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]