Hello,
I'm making a short concept game following one character. You can get three endings depending on your conversations. With your choices, you can either increase the value of his love, friendship, or anger.
To do this, I have been using $. For example: $ anger += 1
For the ending, I want to have whichever of the three variables is the highest to lead to an ending. However, I'm not sure how to make Ren'Py find that value.
I was first going to just make if else statements because I understand those for the most part, but that doesn't seem to fit.
On top of the above, I'd also like to know what I should do if after Ren'Py finds the highest variable, there is a tie. Would it error out if that happened?
Thank you very much!
Finding the Highest Value of Variables for Endings
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.
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.
Re: Finding the Highest Value of Variables for Endings
There's a more conceptual question here (for instance, how are you going to do tiebreakers? It's not so much a question of errors as you just have to decide what happens if there is one), but if statements should be fine for the mechanics. There are only three possible outcomes anyway.
Code: Select all
if a > b and a > c:
"a is larger than both b and c"
elif b > a and b > c:
"b is larger than both a and c"
elif c > a and c > b:
"c is larger than both a and b"
else:
"something went wrong"
- xavimat
- Eileen-Class Veteran
- Posts: 1461
- Joined: Sat Feb 25, 2012 8:45 pm
- Completed: Yeshua, Jesus Life, Cops&Robbers
- Projects: Fear&Love
- Organization: Pilgrim Creations
- Github: xavi-mat
- itch: pilgrimcreations
- Location: Spain
- Discord: xavimat
- Contact:
Re: Finding the Highest Value of Variables for Endings
First, you need to decide what ending has priority in case of a tie. Say if all three variables have the same value, what ending should renpy choose?
(OR you could write 7 endings, because there are seven possibilities counting ties and no-ties, but let's stick to your three endings).
For example, you want it hard for the player, and, in case of a tie, you choose the worst option, so the order of priority is: anger, friendship, love. The code could be:
The trick is in the >= part.
(OR you could write 7 endings, because there are seven possibilities counting ties and no-ties, but let's stick to your three endings).
For example, you want it hard for the player, and, in case of a tie, you choose the worst option, so the order of priority is: anger, friendship, love. The code could be:
Code: Select all
if anger >= max(friendship, love):
jump anger_ending
elif friendship >= love:
jump friendship_ending
else:
jump love_ending
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)
Re: Finding the Highest Value of Variables for Endings
Also, check PyTom's article - https://patreon.renpy.org/picking-a-winner.html
Re: Finding the Highest Value of Variables for Endings
THANK YOU SO MUCH, YOU GUYS. You explained it very well.
And thank you for the link! I definitely have a lot of reading to do as I continue to work and find new problems.
Have a great day~!
And thank you for the link! I definitely have a lot of reading to do as I continue to work and find new problems.
Have a great day~!