Help with "if" statements?

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
charmandy
Newbie
Posts: 6
Joined: Sun Apr 09, 2017 2:21 am
Contact:

Help with "if" statements?

#1 Post by charmandy »

This is probably extremely basic stuff, but I can't find exactly what I'm looking for with the tutorials. Thank you in advance!

The layout of our game is set up like this. There are 40 scenes, with 3 routes. 10 scenes per character, and 10 main scenes. It goes like this:

Main Scene 1 - > (choose which route, A, B, or C. for example, A) -> A Scene 1 -> Main Scene 2 ->A Scene 2 -> Main Scene 3 -> A Scene 3, etc etc.
So, each time you play the game, you can choose to "follow" any of the three characters. Your first choice determines how the rest of your playthrough goes, though all 3 routes share the same "main" scenes.

This is the menu that makes the first big decision:

menu:

"Follow Beverly":

jump b01

"Follow Casey":

jump c01

"Follow Gregory":

jump t01

What sort of "if" statement would I put in, and where? Before the label start, after? Sorry if this is very basic, I'm still learning and having trouble finding information. Thank you so much!

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Help with "if" statements?

#2 Post by Remix »

You wouldn't need an if, you'd just want a variable...
P.S. In future wrap your code in formatting tags:
[code]Your code here[/code]

Code: Select all

default chosen_route = "bev"

label start:
    menu:
        "Follow Beverly":
            $ chosen_route = "bev"

        "Follow Casey":
            $ chosen_route = "cas"

        "Follow Gregory":
            $ chosen_route = "greg"

    jump expression "{}_scene_1".format( chosen_route )
    # 
    # the expression bit just says evaluate it, the {} is replaced by the route

label bev_scene_1:
    "This shows if we chose Beverley"

    jump main_scene_1

label main_scene_1:
    "some stuff"

    jump expression "{}_scene_2".format( chosen_route ) # onto route scene 2...
Hope that makes sense
Frameworks & Scriptlets:

charmandy
Newbie
Posts: 6
Joined: Sun Apr 09, 2017 2:21 am
Contact:

Re: Help with "if" statements?

#3 Post by charmandy »

That's perfect, thank you so much! We were able to get the whole thing coded right, woohoo.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Andredron, Google [Bot]