Page 1 of 1

Multiple Text Inputs on Same Screen (and other misc text input woes)

Posted: Mon Jun 28, 2021 4:24 pm
by StValentines
Hey, slowly-learning Renpy noob here with another undoubtedly not-that-hard problem I can't figure out!

Near the beginning of a game I'm working on, I have a screen for the player to select their anatomy, how they'll be referred to, and to name both the protagonist and the inn they run. Screenshot attached, please ignore the shitty assets and UI design; they are obviously not final.

After a bit of googling and borrowing code, I figured out how to let the player input the text in the actual windows up at the top, rather than using textbuttons that open text input in the dialogue screen. I've attached the code for these two input boxes below:

Code: Select all

screen innkeepercustomization:
    frame:
        xpos 150 ypos 50
        xminimum 350
        xmaximum 350

        has vbox

        vbox:
            label _("Innkeeper Name:")
            input default "Innkeeper"

    frame:
        xpos 650 ypos 50
        xminimum 350
        xmaximum 350

        has vbox

        vbox:
            label _("Inn Name:")
            input default "The Aftercare Inn"
But now I'm running into a number of things that I just don't know how to do within this new setup:

- The player needs to be able to click on these two text fields to select them and type; right now, only the inn name is selected and there's no way to select the innkeeper's name and enter it.
- I need whatever is entered to be bound to variables, so I can reflect the chosen names in the text of the game.
- I need to limit the length of the entered names to ensure they don't extend beyond the vbox boundaries.
- EDIT: Just realized I'd want the text for the custom honorifics to be presented the same way; can I have a text input option in that radio menu on the bottom left?

The first is just a new problem I don't have any idea how to deal with, and the other two are things I knew how to do back when these were just textbuttons that opened an input window, but can't figure out now that I have the text in their own frames. Any help making this work would be appreciated!!

Re: Multiple Text Inputs on Same Screen (and other misc text input woes)

Posted: Tue Jun 29, 2021 6:45 am
by parttimestorier
I just finished putting together a screen a bit like this myself! I'm still not the most experienced coder, but maybe you'd find this thread where I posted some of my code and got some tips about it helpful. My last comment in it has my updated code with multiple inputs working, including setting variables and limiting how long the input can be (that's the "length 30" you see in there, although I ended up adjusting it to be shorter after that as well).

Re: Multiple Text Inputs on Same Screen (and other misc text input woes)

Posted: Tue Jun 29, 2021 6:07 pm
by StValentines
parttimestorier wrote:
Tue Jun 29, 2021 6:45 am
I just finished putting together a screen a bit like this myself! I'm still not the most experienced coder, but maybe you'd find this thread where I posted some of my code and got some tips about it helpful. My last comment in it has my updated code with multiple inputs working, including setting variables and limiting how long the input can be (that's the "length 30" you see in there, although I ended up adjusting it to be shorter after that as well).
Thanks, that helps a lot!!

That said, I can't get it to work for some reason? I took your code and replaced all instances of the "mcfirst" and "mclast" variables with the ones I need ("povname" and "innname"), but it keeps telling me an exception has occurred with "povname" in the first screen variable input value. Here's my version of the code, just to compare:

Code: Select all

    default povname_value = ScreenVariableInputValue("povname")
    default innname_value = ScreenVariableInputValue("innname")
    default active_input = 1

    vbox:
        xpos 150
        ypos 50
        spacing 10
        xsize 200
        label "Innkeeper Name:"
        frame:
            xalign 0.5
            xfill True
            padding (10,10)
            if active_input == 1:
                input value ScreenVariableInputValue("povname") pixel_width 200 length 30 #this is where the exception seems to occur
            else:
                textbutton "[povname]" action SetScreenVariable("active_input", 1)
    vbox:
        xpos 650
        ypos 50
        spacing 10
        xsize 200
        label "Inn Name:"
        frame:
            xalign 0.5
            xfill True
            padding (10,10)
            if active_input == 2:
                input value ScreenVariableInputValue("innname") pixel_width 200 length 30
            else:
                textbutton "[innname]" action SetScreenVariable("active_input", 2)
Any idea why this might be happening? I'm sure I'm just missing something stupid, but I can't for the life of me figure out what could be going wrong since I just replaced the variable names. I also changed the x and y positions and labels, but that doesn't seem to be the source of the problem.

EDIT: Just to try, I pasted it in unedited, too. Same thing happened. Is there something else I'm supposed to put somewhere?

Re: Multiple Text Inputs on Same Screen (and other misc text input woes)

Posted: Tue Jun 29, 2021 6:51 pm
by StValentines
UPDATE: Okay so I messed around and got it working, with just a few changes. I'll admit I'm not sure which one actually fixed it. Thanks so much for your help!!!