Multiple Ending scripting

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.
Message
Author
User avatar
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Multiple Ending scripting

#1 Post by EriksBlue »

What script do I use to have certain endings play based off choices you made.

1) Through menus choices.

2) Through stats.

Please be specific I've been rather lost when working with renpy.
Last edited by EriksBlue on Mon May 09, 2022 11:12 pm, edited 1 time in total.
Image

Chushiki Maho
Regular
Posts: 174
Joined: Wed Jan 04, 2012 3:28 pm
Projects: X-Tasy, Teacher Pets, Virus
Organization: Infinite Scribbles Productions
Location: Check Your Closet.
Contact:

Re: Multiple Ending scripting

#2 Post by Chushiki Maho »

Okay, I'll explain through menu choices, you'll probably need someone else for stats.

The way I do it is usually is:

Code: Select all

menu: 

"Choice 1.":
jump label 1

"Choice 2.":
jump label 2

label 1:

$ choice_1 = True

jump end

label 2:

$ choice_2 = True

jump end

label end:

if choice_1 = True:
jump end1

elif choice_2 = True:
jump end2
X-Tasy - GXB (WIP)
~ My Fanfiction
Virus [NaNoRenO 2012]
French to English (or vice-versa) VN translator ~ PM me if interested :3

redeyesblackpanda
Eileen-Class Veteran
Posts: 1006
Joined: Thu Dec 22, 2011 4:26 am
Projects: Eternal Memories, plot bunnies that won't die.
Organization: HellPanda Studios
Location: United States
Contact:

Re: Multiple Ending scripting

#3 Post by redeyesblackpanda »

In terms of keeping track of points, there's more information here: http://www.renpy.org/wiki/renpy/doc/tut ... Based_Game
(All projects currently on a hiatus of sorts. I blame life.)
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in. :mrgreen:
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.

NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.

User avatar
Starshine
Veteran
Posts: 247
Joined: Mon Jan 30, 2012 7:50 am
Completed: http://berry-melon.blogspot.co.uk/2016/ ... -2016.html
Projects: Pancake Surprise (2016)
Tumblr: http://bettybooplover.tumblr.com
Deviantart: berry-melon
Soundcloud: sweepea-1
Contact:

Re: Multiple Ending scripting

#4 Post by Starshine »

EriksBlue wrote:What script do I use to have certain endings play based of choices you made.

1) Through menus choices.

2) Through stats.

Please be specific I've been rather lost when working with renpy.
I dont understand the stats either, hopefully someone will help us out.
http://berry-melon.blogspot.com
I'm not resting until I find
What would make your eyes
Glisten like mine
With loves divine!

Boo-Boo I couldn't aspire....to anything...
Higher...than to fill that one desire to make it
My own....Bop-Bop-a-Dop-Boop-Oop-a-Doop honey?

redeyesblackpanda
Eileen-Class Veteran
Posts: 1006
Joined: Thu Dec 22, 2011 4:26 am
Projects: Eternal Memories, plot bunnies that won't die.
Organization: HellPanda Studios
Location: United States
Contact:

Re: Multiple Ending scripting

#5 Post by redeyesblackpanda »

Like I said in the post above, this link should help with that: http://www.renpy.org/wiki/renpy/doc/tut ... Based_Game

Basically, you add points or subtract them using += or -= and you can have the relationships between points determine the ending.
(All projects currently on a hiatus of sorts. I blame life.)
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in. :mrgreen:
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.

NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.

User avatar
Starshine
Veteran
Posts: 247
Joined: Mon Jan 30, 2012 7:50 am
Completed: http://berry-melon.blogspot.co.uk/2016/ ... -2016.html
Projects: Pancake Surprise (2016)
Tumblr: http://bettybooplover.tumblr.com
Deviantart: berry-melon
Soundcloud: sweepea-1
Contact:

Re: Multiple Ending scripting

#6 Post by Starshine »

redeyesblackpanda wrote:Like I said in the post above, this link should help with that: http://www.renpy.org/wiki/renpy/doc/tut ... Based_Game

Basically, you add points or subtract them using += or -= and you can have the relationships between points determine the ending.
So basically the points are invisible? and it adds and takes away, which ever choices you choose, depending on where you put the codes, and when a certain number adds up in total, you should get one of the endings. I thought there would be some numbers in the corner.
http://berry-melon.blogspot.com
I'm not resting until I find
What would make your eyes
Glisten like mine
With loves divine!

Boo-Boo I couldn't aspire....to anything...
Higher...than to fill that one desire to make it
My own....Bop-Bop-a-Dop-Boop-Oop-a-Doop honey?

redeyesblackpanda
Eileen-Class Veteran
Posts: 1006
Joined: Thu Dec 22, 2011 4:26 am
Projects: Eternal Memories, plot bunnies that won't die.
Organization: HellPanda Studios
Location: United States
Contact:

Re: Multiple Ending scripting

#7 Post by redeyesblackpanda »

Ah, to show numbers takes more programming. The cookbook has a recipe for that: http://www.renpy.org/wiki/renpy/doc/coo ... ion_Screen
(All projects currently on a hiatus of sorts. I blame life.)
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in. :mrgreen:
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.

NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.

User avatar
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Re: Multiple Ending scripting

#8 Post by EriksBlue »

What if there is a choice early on in the game but effects whether you see certain scenes later in the game how would I script that?
Image

User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

Re: Multiple Ending scripting

#9 Post by SusanTheCat »

So lets say that early on the Main Character has the choice to buy some gum or buy a chocolate bar.

Code: Select all

# Player starts with twenty money
$ money = 20
menu:
    "Buy Gum":
        $ item_bought = "gum"
        $ money -= 5 //subtract 5 from money
    "Buy Chocolate":
        $ item_bought = "chocolate"
        $ money -= 10 //subtract 10 from money
We have two kind of variables/stats there. "money" is a number that we can use to see how much money the player has. "item_bought" is a box that we put the name of what they bought in.

So you go on with your game.


It is now several scene later when you meet up with a little kid that is crying. The player decides to give them something.
You use an if statement to make a decision.

Code: Select all

if item_bought == "gum":
    crying_kid "I hate gum!"


if item_bought == "chocolate":
    crying_kid "I love chocolate!"
Or lets say the player character has a chance to go to an amusement park. But does he have enough money?

Code: Select all

if money >= 15: //does he have at least 15 money?
    jump amusementpark_scene
else:
    jump forever_alone_scene
That is just a shortened version of the excellent link @redeyesblackpanda provided. But sometime another explanation is useful for understanding.

Susan
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas

User avatar
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Re: Multiple Ending scripting

#10 Post by EriksBlue »

Will this script work if I wanted a choice to effect whether a certain dialogue segment is played later on in the game. Also is their a certain type of script needed to end that segment of dialogue. Like jump end.
Image

redeyesblackpanda
Eileen-Class Veteran
Posts: 1006
Joined: Thu Dec 22, 2011 4:26 am
Projects: Eternal Memories, plot bunnies that won't die.
Organization: HellPanda Studios
Location: United States
Contact:

Re: Multiple Ending scripting

#11 Post by redeyesblackpanda »

I don't quite understand what you're asking, but I think an understanding of python if statements would answer your question: http://www.renpy.org/wiki/renpy/doc/tut ... Statements

You have to remember to define the variable at the beginning, and you can also use "if not" if you want it to happen if it's False. Make sure to write "True" or "False" and not "true" or "false"

To jump back to the main menu and "end" the game (I think that's what you're asking) you can use "return"
You use "return" like this (taken from "The Question" which I recommend studying if you're new):

Code: Select all

label later:

    scene black
    with dissolve

    "And so I decided to ask her later."
    "But I was indecisive."
    "I couldn't ask her that day, and I couldn't ask her later."
    "I guess I will never know now."
    
    ".:. Bad Ending."

    return
(All projects currently on a hiatus of sorts. I blame life.)
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in. :mrgreen:
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.

NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.

User avatar
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Re: Multiple Ending scripting

#12 Post by EriksBlue »

I think your explaining it perfectly fine i think its my lack of experience with renpy that’s holding me down.

Basically what I’m saying is: You make a choice and now certain scenes are not available to you. Then when playing the game again, If you made the right choice now those scenes are available but the ones that you got instead are now no loner available.
Image

redeyesblackpanda
Eileen-Class Veteran
Posts: 1006
Joined: Thu Dec 22, 2011 4:26 am
Projects: Eternal Memories, plot bunnies that won't die.
Organization: HellPanda Studios
Location: United States
Contact:

Re: Multiple Ending scripting

#13 Post by redeyesblackpanda »

Ah, I think you're interested in persistent data: http://www.renpy.org/wiki/renpy/doc/ref ... stent_Data
(All projects currently on a hiatus of sorts. I blame life.)
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in. :mrgreen:
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.

NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.

User avatar
EriksBlue
Regular
Posts: 36
Joined: Tue Jul 19, 2011 3:56 pm
Projects: Torn Apart
Location: California
Contact:

Re: Multiple Ending scripting

#14 Post by EriksBlue »

This is what I’m trying to do. Example: Jeff has a choice between going to the zoo and eating. Jeff chooses to go to the zoo. So for now on any dialogue that was in the script saying he went to the restaurant is hidden(this dialogue being farther in the game and not being the first result of the choice you made.)

So how do I script so those segments of dialogue are not shown?

Thank you for helping me I truly do appreciate it.
Last edited by EriksBlue on Mon May 09, 2022 11:13 pm, edited 1 time in total.
Image

vociferocity
Regular
Posts: 93
Joined: Sat Jun 12, 2010 11:27 am
Projects: Rogue of Heart, Valkyrie
Contact:

Re: Multiple Ending scripting

#15 Post by vociferocity »

basically it's not that you want to hide the restaurant dialogue, it's that you only want to show it if he decided to eat. so at first you would have something like

Code: Select all

     label sceneone:
    jeff "what do I want to do now?"
    menu:
        "I want to go to the zoo!":
            $ decision = "zoo"
            jeff "I had an excellent time at the zoo!"
            jump scenetwo
        "I want to eat!":
            $ decision = "food"
            jeff "mmm, that food sure was tasty!"
            jump scenetwo
you can set a variable depending on what menu decision you've picked. and then later in the script you can have something like this:

Code: Select all

    label scenetwo
    mary "so what did you do today, dear?"
    
    if decision == "zoo":
        jeff "I went to the zoo! they have some great animals there"
    elif decision == "food":
        jeff "I went to the restaurant! they have great food there"
which will display one of the two lines of dialogue, depending on your earlier decision. there are a few important things here: notice that in the if statement, I've used two equal signs. if I use one instead, it will just set decision to "zoo", or whatever, and ruin your code.
also, "elif". basically an if statement can be "if X, then Y", "if X, then Y, else Z", or "if X, then Y, elif A, then B, elif 1, then 2, else Z". if you only have two things your variable can be, you should just use if/else, but if you have a whole bunch (for instance, if you had a whole town full of options for jeff to choose between), then you'll need to use "elif" to keep your if statement going. "elif" basically just stands for "else if", btw.

Post Reply

Who is online

Users browsing this forum: No registered users