Persistent Input Option (Preferences Screen)

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
4listair
Newbie
Posts: 11
Joined: Tue Jul 31, 2018 10:54 pm
Contact:

Persistent Input Option (Preferences Screen)

#1 Post by 4listair » Wed Sep 05, 2018 3:56 pm

I'm trying to make a persistent input option in the Preferences screen and I can't seem to get it to work.

Before the start label in script, I put

Code: Select all

label defaultname:
    default pn=""
And then in the preferences screen, I added

Code: Select all

                vbox:
                    style_prefix "name"
                    label _("Change Your Name")
                    textbutton _("YES") action Show("namescreen")
Which jumps to

Code: Select all

screen namescreen():
    zorder 1000

    vbox:
        xalign 0.5
        yalign 0.5
        if not persistent.playername:
            text ("What is your name?")
            input value VariableInputValue("pn")
            $ persistent.playername = pn
            $ renpy.save_persistent()
            textbutton _("OK") action Hide("namescreen")
        else:
            $ pn=persistent.playername
            text ("What is your name?")
            text ("NAME")
            input value VariableInputValue("pn")
            textbutton _("OK") action Hide("namescreen")
It'll save the name, but it won't save as persistent. Any ideas? Thanks!

philat
Eileen-Class Veteran
Posts: 1692
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Persistent Input Option (Preferences Screen)

#2 Post by philat » Wed Sep 05, 2018 11:22 pm

Code: Select all

label start:
    show screen temp # for debugging
    show screen namescreen
    pause
    pause

default pn = ""

screen temp:
    text str(persistent.playername)

screen namescreen():
    zorder 1000

    vbox:
        xalign 0.5
        yalign 0.5
        text ("What is your name?")
        input value VariableInputValue("pn")
        textbutton _("OK") action SetField(persistent, "playername", pn), Hide("namescreen")

User avatar
MaydohMaydoh
Regular
Posts: 101
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: Persistent Input Option (Preferences Screen)

#3 Post by MaydohMaydoh » Thu Sep 06, 2018 11:07 am

Would be better using FieldInputValue instead to directly change the persistent and and get rid of the pn variable.

philat
Eileen-Class Veteran
Posts: 1692
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Persistent Input Option (Preferences Screen)

#4 Post by philat » Fri Sep 07, 2018 2:51 am

Good call. I don't use inputs much so I didn't realize that existed.

Post Reply

Who is online

Users browsing this forum: drKlauz, Kinmoku