Input name leads to error logs

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
User avatar
soymilk
Newbie
Posts: 5
Joined: Sat Apr 25, 2020 7:11 pm
Projects: Hopelessly Romantic
Organization: Refined Rodents
IRC Nick: soymilk
Location: Earth
Contact:

Input name leads to error logs

#1 Post by soymilk »

I'm trying to have it so that when you press "New Game" you're prompted with a text box so you can enter a name.

Code: Select all

init python:
    def FinishEnterName():
        if not player: return
        persistent.playername = player
        renpy.hide_screen("name_input")
        renpy.jump_out_of_context("start")

screen navigation():

    vbox:
        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign 0.8

        spacing gui.navigation_spacing

        if not persistent.autoload or not main_menu:

            if main_menu:

                if persistent.playthrough == 1:
                    textbutton _("Continue") action If(persistent.playername, true=Start(), false=Show(screen="name_input", message="Please enter your name", ok_action=Function(FinishEnterName)))
                else:
                    textbutton _("New Game") action If(persistent.playername, true=Start(), false=Show(screen="name_input", message="Please enter your name", ok_action=Function(FinishEnterName)))

            else:
the "else" being textbuttons for history, save game, etc.

When trying to execute the code by pressing "New Game", instead I'm given this error:

Code: Select all

"While running game code:
        File "renpy/common/00action_control.rpy" , line 126, in__call__
           renpy.show_screen(self.screen, *self.args, **self.kwargs)
        Exception: Screen name_input is not known."
Followed by a full traceback.
Full error log
Full error log
I can skip this error, however, in doing so I get the player name as "%(pn)s" which is the player input placeholder in the script.
The "Load Game" Execution works just fine, prompting with save files to use.

I have a feeling it may have something to do with "%(pn)s" and "persistent.playername = player" from the beginning of the code in screen. Any ideas?
Thank you for reading, please have a nice day <3

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Input name leads to error logs

#2 Post by gas »

But there's any screen called "name_input" somewhere? At what init step?

(I'm not also sure that's so safe to exit from the 'start'[!?] context with a called function...)

The whole thing can be simply staged at the very beginning of the start label...
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
soymilk
Newbie
Posts: 5
Joined: Sat Apr 25, 2020 7:11 pm
Projects: Hopelessly Romantic
Organization: Refined Rodents
IRC Nick: soymilk
Location: Earth
Contact:

Re: Input name leads to error logs

#3 Post by soymilk »

What do you mean "init step"? And how would I manage to replicate this with a start label when still having the pop up be at the main menu? I still want the main menu to be there but a pop up asking for a name input.

Also, what do you mean by it not being safe? Should I be concerned about something?

I'm very new to coding and I really appreciate you trying to help out, it would be amazing if you could further alliterate.
Thank you for reading, please have a nice day <3

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Input name leads to error logs

#4 Post by gas »

If you're new to coding the explanation will be out of your reach.

How can you code a function that way without coding skills? That's not a code of your, supposedly :wink: .
Anyway, had you first checked if there's actually a screen called "name_input" somehwere? And if so, where it is?
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
soymilk
Newbie
Posts: 5
Joined: Sat Apr 25, 2020 7:11 pm
Projects: Hopelessly Romantic
Organization: Refined Rodents
IRC Nick: soymilk
Location: Earth
Contact:

Re: Input name leads to error logs

#5 Post by soymilk »

Actually, a friend of mine gave me that piece saying it would help... however he isn't sure either how to work it sooo I'm looking for alternatives.

There is a screen_input, but only in that blurb of code. Nowhere else. Do you think that could be the issue? :O
Thank you for reading, please have a nice day <3

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Input name leads to error logs

#6 Post by hell_oh_world »

maybe try using `use` then a condition to toggle it, you might need to also add modal true to the input screen...

Code: Select all

default show_input = False

screen name_input(message):
    default the_input = ""
    modal True
    
    vbox:
        input: # modified input code without using a function...
            default message
            value ScreenVariableInputValue("the_input") # Try VariableInputValue("the_input") if this action throws an error...
            
            hbox:
                textbutton "Proceed" action If(the_input.strip(), [ SetVariable("persistent.playername", the_input), Start() ], NullAction())
                textbutton "Cancel" action SetVariable("show_input", False)

screen navigation():
    default texts = (_("Continue"), _("New Game")) # the textbutton texts...

    vbox:
        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign 0.8

        spacing gui.navigation_spacing

        if not persistent.autoload or not main_menu:

            if main_menu:

                $ the_text = texts[0] if persistent.playthrough == 1 else texts[1]
                textbutton the_text action If(persistent.playername, Start(), SetVariable("show_input", True)) # the buttons...

            else:
                # other codes...
     
    if show_input:
        use input(message="Please enter your name") # the input, put as the last line of the screen and add modal to the name_input to prevent interaction from other screen elements other than the input itself.

Post Reply

Who is online

Users browsing this forum: Kocker