Text Input on screens

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
DoubleProlix
Regular
Posts: 33
Joined: Thu Oct 19, 2017 8:04 pm
Contact:

Text Input on screens

#1 Post by DoubleProlix »

I've got a character creation screen that allows players to choose their various options via radio buttons. It's working fine, but I'd like to allow them to set the character's name on the screen as well.

(Currently the name is set through standard renpy.input statements outside of the custom character creation screen, which works, but I'd like to consolidate everything here.)

So I've got my character creation screen called at the start of my start: loop with

Code: Select all

call screen characterCreation
The screen itself is all hboxes and vboxes and radio buttons, who accurately assign values to variables with action(setVariable) as needed. When the player is done, they click an OK button with an action Return() bringing them back to the start label. Character complete, they can get on with the game.

So I can create input labels at the top of the screen with something like

Code: Select all

                    text "First name:   "
                    input default "John"
but how do I get that input into the variable firstname?

edit: I've turned the inputs into

Code: Select all

input value VariableInputValue("firstname")
but now I can't seem to switch the focus between them. I can edit firstname's default text all I like and it works.

What I have so far:

Code: Select all

screen characterCreation():

    tag menu

    if renpy.mobile:
        $ cols = 2
    else:
        $ cols = 3

    use game_menu(_("Character Creation"), scroll="viewport"):

        vbox:
            hbox:
                    text "First name:   "
                    input value VariableInputValue("firstname")
                 
            #hbox:
                    
                    text "Surname:      \n\n"
                    input value VariableInputValue("surname")
Current Project: Thaumarotica - an occult erotic thriller
SubscribeStar - Patreon - Itch.io

Shie
Regular
Posts: 41
Joined: Sun Apr 14, 2019 4:12 am
itch: shie
Discord: shie_3769
Contact:

Re: Text Input on screens

#2 Post by Shie »

I know, that is unbelievably late answer, but i just had same problem. In case someone will meet such problem, here is solution:

You need variable, that will show what you editing right now

Code: Select all

default focus_number = 0
So that in your screen you can use this

Code: Select all

#instead of this line:
#input value VariableInputValue("firstname")

#write this
if focus_number == 1:
    input value VariableInputValue("firstname")
else:
    textbutton "default value or variable value" action SetVariable("focus_number",1)
With another input do same, but with number 2

It not best solution, but it works. Maybe someone will do better than i

Post Reply

Who is online

Users browsing this forum: Google [Bot]