(SOLVED, after much suffering) Weird Bug: Some (Not All) Input Screens Clashing with Hotkeys

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
Sumoslap
Regular
Posts: 59
Joined: Tue Oct 12, 2010 10:02 pm
Contact:

(SOLVED, after much suffering) Weird Bug: Some (Not All) Input Screens Clashing with Hotkeys

#1 Post by Sumoslap » Sun Apr 10, 2022 7:54 pm

Would really be grateful for help, as this is a maddening bug!

I have a series of input screens I use for character creation at the start of the game. For weeks, they've all been working fine.

Today, the sixth input screen, which uses the exact same code as the previous five, decided to sometimes activate hotkey commands and/or not accept typed input.

To be clear, I will type the first letter in the sixth input screen, and it works fine. I type the second letter, and it either does nothing, or if it's a hotkey, it activates a hotkey.

The problem also exists with the seventh input screen.

I have tried many solutions, including rewriting the code from the ground up, making a whole new game and copying/pasting the rewritten code there, deleting persistent data and forcing a recompile, and deleting saved games.

I feel like I may have introduced a bug that damaged something deeper than anything I know how to fix. Is there anything else I can purge to try to clean out whatever bug is there, and reinstall as necessary?

Here is the screen code. The last two screens are the problem-children. Note: this is sloppy and not optimized. I am iterating quickly. Basically, I am sure it's inelegant, but the bug didn't seem to have anything to do with that. :)

Code: Select all

screen countCharactersName():
    $ characterLength = len(pcname)
    text "[characterLength]/25":
        xalign 0.8
        yalign 0.3

screen countCharactersAppearance():
    $ characterLength = len(appearance)
    text "[characterLength]/250":
        xalign 0.8
        yalign 0.4

screen countCharactersSkill():
    $ characterLength = len(skill)
    text "[characterLength]/250":
        xalign 0.8
        yalign 0.4

screen countCharactersWorkOn():
    $ characterLength = len(workOn)
    text "[characterLength]/250":
        xalign 0.8
        yalign 0.4

screen countCharactersPossession():
    $ characterLength = len(possession)
    text "[characterLength]/250":
        xalign 0.8
        yalign 0.4

screen countCharactersBigChange():
    $ characterLength = len(bigChange)
    text "[characterLength]/250":
        xalign 0.8
        yalign 0.4

screen enterName():
    vbox:
        xalign 0.5
        yalign 0.5
        input:
            xalign 0.5
            yalign 0.5
            default "You didn't write a name."
            length 25
            value VariableInputValue("pcname")
            copypaste True
        frame:
            xpadding 40
            ypadding 15
            xalign 0.5
            yanchor 0.5
            ypos 0.7
            textbutton "Confirm" action Jump ("confirmName")

screen nameConfirm():
    vbox:
        xanchor 0.5
        xpos 0.5
        yalign 0.55
        spacing 20
        text "You gave yourself the name {font=NewtSerifBold.otf}{size=+5}[pcname]{/size}{/font}."
        text "Are you happy with your name? If not, you can change it."
        frame:
            xpadding 40
            ypadding 20
            xalign 0.5
            yalign 0.5
            textbutton "I like this name." action Jump ("appearance")
        frame:
            xpadding 40
            ypadding 20
            xalign 0.5
            yalign 0.5
            textbutton "I have a better idea for a name." action Jump ("start")

screen enterAppearance():
    vbox:
        xalign 0.5
        yalign 0.6
        input:
            xalign 0.5
            yalign 0.5
            default "You didn't write anything."
            length 250
            value VariableInputValue("appearance")
            copypaste True
        frame:
            xpadding 40
            ypadding 15
            xalign 0.5
            yanchor 0.5
            ypos 0.7
            textbutton "Confirm" action Jump ("confirmAppearance")

screen appearanceConfirm():
        vbox:
            xanchor 0.5
            xpos 0.5
            yalign 0.9
            spacing 20
            text "You wrote:"
            vbox:
                spacing 50
                xalign 0.5
                yalign 0.5
                text "{font=NewtSerifBold.otf}{size=+5}[appearance]{/size}{/font}"
            text "Are you happy with this description?"
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "Looking good!" action Jump ("skill")
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "I want to refine this description." action Jump ("appearance")

screen enterSkill():
    vbox:
        xalign 0.5
        yalign 0.6
        input:
            xalign 0.5
            yalign 0.5
            default "You didn't write anything."
            length 250
            value VariableInputValue("skill")
            copypaste True
        frame:
            xpadding 40
            ypadding 15
            xalign 0.5
            yanchor 0.5
            ypos 0.7
            textbutton "Confirm" action Jump ("confirmSkill")

screen skillConfirm():
        vbox:
            xanchor 0.5
            xpos 0.5
            yalign 0.9
            spacing 20
            text "You wrote:"
            vbox:
                spacing 50
                xalign 0.5
                yalign 0.5
                text "{font=NewtSerifBold.otf}{size=+5}[skill]{/size}{/font}"
            text "Are you happy with this description?"
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "This will work nicely." action Jump ("needToWorkOn")
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "I want to refine this description." action Jump ("skill")

screen enterWorkOn():
    vbox:
        xalign 0.5
        yalign 0.6
        input:
            xalign 0.5
            yalign 0.5
            default "You didn't write anything."
            length 250
            value VariableInputValue("workOn")
            copypaste True
        frame:
            xpadding 40
            ypadding 15
            xalign 0.5
            yanchor 0.5
            ypos 0.7
            textbutton "Confirm" action Jump ("confirmWorkOn")

screen workOnConfirm():
        vbox:
            xanchor 0.5
            xpos 0.5
            yalign 0.9
            spacing 20
            text "You wrote:"
            vbox:
                spacing 50
                xalign 0.5
                yalign 0.5
                text "{font=NewtSerifBold.otf}{size=+5}[workOn]{/size}{/font}"
            text "Are you happy with this description?"
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "This gives me interesting ideas for roleplaying." action Jump ("possession")
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "I want to refine this description." action Jump ("needToWorkOn")

screen enterPossession():
    vbox:
        xalign 0.5
        yalign 0.6
        input:
            xalign 0.5
            yalign 0.5
            default "You didn't write anything."
            length 250
            value VariableInputValue("possession")
            copypaste True
        frame:
            xpadding 40
            ypadding 15
            xalign 0.5
            yanchor 0.5
            ypos 0.7
            textbutton "Confirm" action Jump ("confirmPossession")

screen possessionConfirm():
        vbox:
            xanchor 0.5
            xpos 0.5
            yalign 0.9
            spacing 20
            text "You wrote:"
            vbox:
                spacing 50
                xalign 0.5
                yalign 0.5
                text "{font=NewtSerifBold.otf}{size=+5}[possession]{/size}{/font}"
            text "Are you happy with this description?"
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "Sure does!" action Jump ("bigChange")
            frame:
                xpadding 40
                ypadding 20
                xalign 0.5
                yalign 0.5
                textbutton "I want to refine this description." action Jump ("possession")
Labels:

Code: Select all

label start:
    camera:
        perspective True
    show screen gameMenu
    scene sepiabg with dissolve
    pause 1

    show text "{size=+15}Character Creation{/size}" at xtop as line1 with dissolve
    pause 1

    show screen countCharactersName

    $ renpy.transition(dissolve)
    show text "What is your name?"at x2 as line2

    call screen enterName

    $ renpy.transition(dissolve)

label confirmName:
    hide screen countCharactersName
    call screen nameConfirm

    $ renpy.pause(0.0)

label appearance:

    hide line2
    pause (.5)

    show screen countCharactersAppearance

    $ renpy.transition(dissolve)
    show text "What kind of impression do your clothing and demeanor give others? How do you see yourself?"at x2 as line2 with dissolve

    call screen enterAppearance
    $ renpy.transition(dissolve)

label confirmAppearance:
    hide screen countCharactersAppearance
    call screen appearanceConfirm

    $ renpy.pause(0.0)

label skill:

    hide line2
    pause (.5)

    show text "What's something you're really good at? How has being good at this skill affected your life?" at x2 as line2 with dissolve

    show screen countCharactersSkill

    $ renpy.transition(dissolve)

    call screen enterSkill
    $ renpy.transition(dissolve)

label confirmSkill:
    hide screen countCharactersSkill
    call screen skillConfirm

    $ renpy.pause(0.0)

label needToWorkOn:

    hide line2
    pause (.5)

    show screen countCharactersWorkOn

    show text "What's something about yourself you really need to work on?" at x2 as line2 with dissolve

    $ renpy.transition(dissolve)

    call screen enterWorkOn
    $ renpy.transition(dissolve)

label confirmWorkOn:
    hide screen countCharactersWorkOn
    call screen workOnConfirm

    $ renpy.pause(0.0)

label possession:

    hide line2
    pause (.5)

    show screen countCharactersPossession

    $ renpy.transition(dissolve)
    show text "What possession do you treasure more than any other?"at x2 as line2 with dissolve

    call screen enterPossession
    $ renpy.transition(dissolve)

label confirmPossession:
    hide screen countCharactersPossession
    call screen possessionConfirm

    $ renpy.pause(0.0)
Last edited by Sumoslap on Fri Apr 15, 2022 6:22 pm, edited 1 time in total.

jeffster
Regular
Posts: 123
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Weird Bug: Some (Not All) Input Screens Clashing with Hotkeys

#2 Post by jeffster » Mon Apr 11, 2022 6:36 am

I haven't studied your code thoroughly but it seems that similar screens should be integrated in one screen:

Code: Select all

default mc = {
    "pcname": "You didn't write the name.",
    "appearance": "You didn't describe the appearance.",
    #...
}

screen enter_string(mc_key, prompt, maxlength = 250):
    $ length = len(mc[mc_key])
    frame:
        background "#864"
        xalign 0.5
        yalign 0.5
        xfill True      # or set some xsize
        vbox:
            text "[length]/[maxlength]" xalign 1.0 size 24

            text "[prompt]" size 36 xalign 0.5

            frame:
                background "#468"
                xfill True
                input:
                    xalign 0.5
                    length maxlength
                    value DictInputValue(mc, mc_key, returnable = True)
                    copypaste True

            textbutton "OK":
                action Return()
                xpadding 40
                ypadding 15
                xalign 0.5
                yanchor 0.5
                ypos 0.7
                text_size 36

label start:

    call screen enter_string(
            "pcname",
            "What is your name?",
            25
        )
    $ pcname = mc["pcname"]
    "Your name: [pcname]. Rollback and re-type to change it."

    call screen enter_string(
            "appearance",
            "What kind of impression do your clothing and demeanor give others? How do you see yourself?"
        )
    $ appearance = mc["appearance"]
    "Your appearance: [appearance]."
    "Rollback and re-type to change it."

    #...

User avatar
Sumoslap
Regular
Posts: 59
Joined: Tue Oct 12, 2010 10:02 pm
Contact:

Re: Weird Bug: Some (Not All) Input Screens Clashing with Hotkeys

#3 Post by Sumoslap » Mon Apr 11, 2022 10:30 am

Thank you for your reply, Jeffster! Your code doesn't fix my current problem, but it will definitely help me clean up my code.

Would you happen to know where the "secret" save data is stored on a Mac? Basically the equivalent of %appdata% on Windows? I want to erase as much data as possible to try to undo the bug. Thanks!

EDIT: I've found these instructions to clear all saved data on a Mac. It didn't solve my problem, but in the hopes of being helpful to someone, here is how I did it--

Your Ren'py save files on Mac can be found at this path:

~/Library/RenPy/game_directory
To access the above path:

Open up a Finder window
Press COMMAND + SHIFT + G
Paste/enter the path (~/Library/RenPy/ <--and then wherever you need to go from here

I am putting this here because I didn't find this here in the forums, and I want people to be able to find where the system saves files on a Mac, equivalent to %appdata% on Windows.

User avatar
Sumoslap
Regular
Posts: 59
Joined: Tue Oct 12, 2010 10:02 pm
Contact:

Re: Weird Bug: Some (Not All) Input Screens Clashing with Hotkeys

#4 Post by Sumoslap » Fri Apr 15, 2022 6:22 pm

Okay, found the issue. Definitely my fault as an amateur coder.

I had a $renpy.transition(dissolve) statement in a screen that I call later in the game. Once I commented it out, everything worked fine.

I did not suspect that a screen I hadn't called yet would cause the problem. I was able to find it because of what PyTom said about transitions in the bug report I filed, plus information I was able to slowly glean from the forms, which told me screens get called all the time. Transitions in screens are bad news IMO.

So, not a bug. That said, it's definitely a trap for newer coders.

My sense now is that transitions should pretty much never be baked into screens. To make this more findable when people search: if you can at all avoid it, don't put transitions in screens. They might throw up weird errors in your game.

Thank you again for your help, Jeffster!

Post Reply

Who is online

Users browsing this forum: enaielei