Page 1 of 2
Multiple Ending scripting
Posted: Sat Mar 03, 2012 7:14 pm
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.
Re: Multiple Ending scripting
Posted: Sat Mar 03, 2012 7:21 pm
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
Re: Multiple Ending scripting
Posted: Sat Mar 03, 2012 8:24 pm
by redeyesblackpanda
In terms of keeping track of points, there's more information here:
http://www.renpy.org/wiki/renpy/doc/tut ... Based_Game
Re: Multiple Ending scripting
Posted: Sat Mar 03, 2012 8:33 pm
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.
Re: Multiple Ending scripting
Posted: Sat Mar 03, 2012 10:10 pm
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.
Re: Multiple Ending scripting
Posted: Sat Mar 03, 2012 11:33 pm
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.
Re: Multiple Ending scripting
Posted: Sat Mar 03, 2012 11:38 pm
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
Re: Multiple Ending scripting
Posted: Sun Mar 04, 2012 12:54 am
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?
Re: Multiple Ending scripting
Posted: Sun Mar 04, 2012 1:16 am
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
Re: Multiple Ending scripting
Posted: Sun Mar 04, 2012 4:02 pm
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.
Re: Multiple Ending scripting
Posted: Sun Mar 04, 2012 4:20 pm
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
Re: Multiple Ending scripting
Posted: Sun Mar 04, 2012 7:24 pm
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.
Re: Multiple Ending scripting
Posted: Sun Mar 04, 2012 7:42 pm
by redeyesblackpanda
Re: Multiple Ending scripting
Posted: Mon Mar 05, 2012 8:25 am
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.
Re: Multiple Ending scripting
Posted: Mon Mar 05, 2012 8:59 am
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.