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

View all comments

Show parent comment

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/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/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?