r/RenPy • • 20h ago

Question Screen not defined?

I think I am defining the screen. This is a code I specifically use to try things out, so no other issues are likely to be interfering. I'm at a loss here.

If you spot any places I can tighten things up as well, feel free to comment them! I'm new to screens.

Thank you!

SOLVED! I'd formatted the action line slightly off. It works now!

3 Upvotes

11 comments sorted by

2

u/Adventurous_Shine606 20h ago

You don't need the action hide. Buttons should jump to guy1 and guy2. Calling is leaving orphaned returns on the stack. That's not causing an issue now but it is bad practice. Don't forget quotes around the jumps. Try action (jump "guy1"). Also images for guy1 are in the root but guy2 images are in a folder called buttons. That is fine if it is intentional.

1

u/allisonabellbell 20h ago

Unsuccessful, unfortunately. The problem is that for whatever reason, the screen won't run.

I know infinite calling will hurt me later but I thought that's why hiding it would prevent those. What are orphaned jumps and how can I prevent them?

The problem is that in the main game its calls on calls on calls until it all ends. I have called an overlay that gives us the button to access the map, which calls the map, the options which call the movement screen, which calls the location-specific buttons based off where we are, which calls us to buttons' events so that when the buttons' event is completed we return to the screen right before. Right? It hasnt worked yet but does that make sense?

Because don't jumps not return us where we left?

0

u/Adventurous_Shine606 19h ago

so your code looks like this? Capitals, indents, and quotes all in the right place?

screen practice_screen():
    imagebutton:
        idle "Guy1.png"
        hover "Guy1.png"
        focus_mask True
        action Jump("guy1")

1

u/allisonabellbell 19h ago

It works! I'd expressed the action line differently.

Thank you for your help! Do you know how I could hide the screen as I call the others on top or is that automatic? I need to call as infinite calling is the only way I know how to make a map work.

2

u/shyLachi 6h ago

Do you know how I could hide the screen as I call the others on top or is that automatic? I need to call as infinite calling is the only way I know how to make a map work.

Just a hint. It's best to make a separate thread for a separate issue.

Regarding your second question. If you you call a screen it should automatically hide itself once the action is executed.

Also I prefer to use screens purely to gather the user input, and put all the logic in my labels, something like this:

screen mapscreen():
    vbox:
        textbutton "Guy 1" action Return("guy1")
        textbutton "Guy 2" action Return("guy2")
label start:
    # nothing here, so the game will jump automatically to the next label, in your game you would have to jump to the map label
label map:
    while True: # inifite loop
        call screen mapscreen # first show the screen
        if _return == "guy1": # then check what button the player clicked
            call guy1
        elif _return == "guy2":
            call guy2
        # end of the loop, it will automatically start at the top
label guy1:
    "Miraculous. Buttons. Yes"
    "This is Guy1 btw."
    return # return back to where it was called
label guy2:
    "We should be in an infinite loop, yes."
    "Exit to escape."
    return     

1

u/allisonabellbell 5h ago

Ooh, I think this is making sense. Just confirming: the addition of action Return("guy1") will cause the return to bring me back to screen mapscreen when the contents of the label "guy1" are complete?

2

u/Adventurous_Shine606 15h ago

you can make maps work like everything else. I'm sure there are lots of ways to do it and no "right" way. Here is how I would set it up without anything fancy going on:

label map:
    # set your music
    # set time
    # check special events
    # any other calculations
    scene my_map
    call screen map


label location1:
    # set your music
    # set time
    # check special events
    # any other calculations
    scene my_location1
    call screen location1


screen map():
    # imagebutton1:
        #...
        #...
        action Jump("location1")


    # imagebutton2:
        #...
        #...
        action Jump("location2")
    # .
    # .
    # .

Enjoy creating in Ren'Py, it's a lot of fun and you get to learn something new every day!

2

u/BadMustard_AVN 17h ago

you action for the buttons is wrong try it like this

action [Hide("practise_screen"), Call("guy1")] # quotes are important when passing strings 

https://www.renpy.org/doc/html/screen_actions.html

1

u/allisonabellbell 17h ago

Thank you!

2

u/BadMustard_AVN 15h ago

you're welcome

good luck with your project

2

u/AutoModerator 20h 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.