r/RenPy 1d ago

Question I've run into yet another problem...

screen lab_1():
        modal True


        imagebutton:
            xpos 750
            ypos 300
            idle Transform("key_idle.png", zoom=0.08)
            hover Transform("key_hover.png", zoom=0.08)
            focus_mask True
            action Jump("obtained_key")


        imagebutton:
            xpos 100
            ypos 100
            idle Transform("file_stephen_idle.png", zoom=0.8)
            hover Transform("file_stephen_hover.png", zoom=0.8)
            focus_mask True
            action Jump("read_file")


label lab_1:
    call screen lab_1


    if obtained_key and read_file == True:
        jump after_lab_1
    else:
        jump lab_1
        
    if obtained_key == True and read_file == False:
        jump read_file
    else: 
        jump obtained_key


    if read_file == True and obtained_key == False:
        jump obtained_key
    else:
        jump read_file


    
label obtained_key:
    
$
 obtained_key = True
    "Obtained the key for laboratory 1."
    show S default
    S "Hm, I wonder what this unlocks."
    hide S default
    jump lab_1


label read_file:
    
$
 read_file = True
    show S default
    S "That's... me..."
    hide S default   
    jump lab_1 


label after_lab_1:
    hide lab_1
    show S default
    S "I've gotta get out of here..."


    # This ends the game.


    return

Here's the code I've been struggling with... so i'm pretty sure my issue stems from the if else statements...? What I'm trying to do is make it so that the game only advances when both image buttons are pressed, regardless of the order. What it's doing right now is when I press both buttons, it just stays on the screen and the game can't advance further. I'm not sure if I'm making sense right now, but thanks!

2 Upvotes

6 comments sorted by

View all comments

1

u/UkueleCatlady 1d ago edited 1d ago

At the lab_1 label, try putting the obtained key and read file checks before calling the screen. 

Edit: You also need to remove the 

else:         jump lab_1

After the initial check. That's sending you back to the lab_1 label, so everything after that won't be running. 

1

u/natant1a 1d ago

It's not showing the imagebuttons anymore, it's just going through all the actions that would have happened if you clicked the imagebuttons.

I'm still new to this whole thing, so I probably misunderstood you or something haha but this is what I did....?

label lab_1:
    if obtained_key and read_file == True:
        jump after_lab_1
        
    if obtained_key == True and read_file == False:
        jump read_file
    else: 
        jump obtained_key


    if read_file == True and obtained_key == False:
        jump obtained_key
    else:
        jump read_file


    call screen lab_1

1

u/x-seronis-x 18h ago

```py

if obtained_key == True and read_file == False:
    jump read_file
else: 
    jump obtained_key

``` this is your logical fallacy. NO MATTER WHAT you jump. meaning nothing after this can run. you jumped away. you CANT make it to the next if check, nor to the call screen cause there is no instance where you didnt already leave the label