Multiple inputs from User in a single page.

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
Yuvan raj
Regular
Posts: 38
Joined: Wed Feb 17, 2021 11:24 am
Contact:

Multiple inputs from User in a single page.

#1 Post by Yuvan raj »

Hello guys, I want to receive inputs(like their name) from the user. I already know how to get a single input. This is my code to get the input from the user.

This is the code in script.rpy

Code: Select all

    $ player_name = renpy.input("What's your first name?") 
    $ player_name = player_name.strip()
    if player_name == "":
        $ player_name="Main character"
This is the another code in a randon .rpy file

Code: Select all

init -2 python:
    class GetText(Action):
        def __init__(self,screen_name,input_id):
            self.screen_name=screen_name
            self.input_id=input_id
        def __call__(self):
            if renpy.get_widget(self.screen_name,self.input_id):
                return str(renpy.get_widget(self.screen_name,self.input_id).content)
And this is the code in screen.rpy

Code: Select all

screen input(prompt):

    frame:
        background Null()
        xpos 21
        ypos 19
        xysize (1334, 731)

        vbox:

            xalign 0.5
            yalign 0.5
            spacing 15

            frame:
                style "frame_gui1"
                xminimum 500
                xmaximum 500

                text prompt at center

            frame:
                style "frame_gui1"
                xminimum 500
                xmaximum 500

                input id "input" at center

            imagebutton auto "ok %s" xpos 0.40 focus_mask True action GetText("input","input")
And this is the result of the above code:
Image

What I want is to get multiple inputs in the same page. I feel like it will make the user feel like they are wasting time typing a lot of things. And also it can help if we need a lot of inputs for several characters.

Below is the result I want(This is a photoshoped pic):

Image

Thank you in advance!

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Multiple inputs from User in a single page.

#2 Post by Alex »

Yuvan raj wrote: Tue Oct 12, 2021 1:52 pm ...What I want is to get multiple inputs in the same page. ...
Try it like - viewtopic.php?f=8&t=61467&p=542714#p542714

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Multiple inputs from User in a single page.

#3 Post by Imperf3kt »

Another way would possibly be to have a button that fills with text based on a variable. The button opens an input screen, player inputs text, text is saved to variable, player closes screen.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Alex, Google [Bot], LegsWild, Toma