Conditional "if" statement

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
This will hopefully be my last question before the launch of the VN :).

In the early part of the VN the player has 3 yes/no choices to make. I want to remember if the player chose Yes to any of those. So I have:
Python:
    menu:

        "Yes":
            $ yes_choice = "true"
            jump somewhere

        "No":
            jump somewhere2
And I have that 3 times, so if any of the choices is Yes, then yes_choice should be true. Now I introduce Character 4 and ask the same question. If you say Yes for her OR for any of the other characters, I want to jump to the yes_screen. If Character 4 is a no but any of the 1-3 characters is a yes, I want to go to the yes_screen. Only if all characters are no do I want to bypass the yes_screen.

I thought I could do it like this,:
Python:
menu:
    "Yes":
        jump yes_screen

    "No":
        if yes_choice== "true":
            jump yes_screen
        else:
            jump somewhere3
But in testing, when I select No for everyone, it returns an error "yes_choice is not defined".
 

sillyrobot

Engaged Member
Apr 22, 2019
2,041
1,809
This will hopefully be my last question before the launch of the VN :).

In the early part of the VN the player has 3 yes/no choices to make. I want to remember if the player chose Yes to any of those. So I have:
Python:
    menu:

        "Yes":
            $ yes_choice = "true"
            jump somewhere

        "No":
            jump somewhere2
And I have that 3 times, so if any of the choices is Yes, then yes_choice should be true. Now I introduce Character 4 and ask the same question. If you say Yes for her OR for any of the other characters, I want to jump to the yes_screen. If Character 4 is a no but any of the 1-3 characters is a yes, I want to go to the yes_screen. Only if all characters are no do I want to bypass the yes_screen.

I thought I could do it like this,:
Python:
menu:
    "Yes":
        jump yes_screen

    "No":
        if yes_choice== "true":
            jump yes_screen
        else:
            jump somewhere3
But in testing, when I select No for everyone, it returns an error "yes_choice is not defined".
I'm no expert, but yes_choice isn't defined if you answered 'No' three times up front. You're only defining it under 'Yes'. Define it to false under the first menu choice of 'No', probably.
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,783
Python:
default yes_choice = False

label start:
    menu:
        "Yes":
            $ yes_choice = True
            jump somewhere
        "No":
            jump somewhere2

label somewhere_else:
    menu:
        "Yes":
            jump yes_screen
        "No":
            if yes_choice:
                jump yes_screen
            else:
                jump somewhere3
 

CarbonBlue

Developer of Unleashed
Game Developer
Oct 25, 2018
1,142
7,740
Python:
default yes_choice = False

label start:
    menu:
        "Yes":
            $ yes_choice = True
            jump somewhere
        "No":
            jump somewhere2

label somewhere_else:
    menu:
        "Yes":
            jump yes_screen
        "No":
            if yes_choice:
                jump yes_screen
            else:
                jump somewhere3
So I don't need to specify that yes_screen is true? Huh. OK. It works! Thank you so much!
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,783
i wouldn't use strings for conditional variables. booleans are there for a reason. and yes, you don't need if yes_choice == True.