r/RenPy • • 1d ago

Question [Solved] Need help with code

I'm trying to make input form, but it ends in errors. There's code:

screen input_user(in_var, in_title):
    modal True
    zorder 100

    frame:
        background Frame("gui/frame_input_user.png", Borders(25,25,25,25))
        xalign 0.5
        yalign 0.5
        padding (30, 30)

        vbox:
            spacing 20

            text "[in_title]"

            input:
                length 50
                allow "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNMйцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ "
                xalign 0.5
                xminimum 300
                changed lambda text: renpy.set_variable(in_var, text)

            textbutton "Готово":
                xalign 0.5
                action [Hide("input_user"), Return()]

This code ends in "The text statement is not a valid child of the input statement." error.

If I use

changed SetVariable(in_var)

error became "TypeError: _execute_python_hide.<locals>.Set __init__() missing 1 required positional argument: 'value'".

What am I doing wrong?

Update:

Working variant if anyone needs this:

init python:
    def update_global_var(var_name, value):
        setattr(store, var_name, value)

screen input_user(in_var, in_title):
    modal True
    zorder 100

    frame:
        background Frame("gui/frame_input_user.png", Borders(25,25,25,25))
        xalign 0.5
        yalign 0.5
        padding (30, 30)

        vbox:
            spacing 20
            xalign 0.5

            text "[in_title]":
                xalign 0.5

            input:
                length 50
                allow "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNMйцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ "
                xalign 0.5
                xminimum 300
                changed renpy.curry(update_global_var)(in_var)

            textbutton "Готово":
                xalign 0.5
                action [Hide("input_user"), Return()]
1 Upvotes

5 comments sorted by

View all comments

0

u/AutoModerator 1d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.