Playthrough does not account for point-based endings, jumps to "else"
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.
-
- Newbie
- Posts: 6
- Joined: Tue Jan 02, 2018 8:12 am
- Contact:
Playthrough does not account for point-based endings, jumps to "else"
I'm working on a dating sim, and according to the "remembering user choices" tutorial on renpy, I can create different endings if one character has more points than the others combined, you can land their ending. This is my code for these endings so far:
label end:
if vicky_bad > max(vicky_good, landon_good, landon_neutral, lyra_good):
jump vickybadending
elif vicky_good > max(vicky_bad, landon_good, landon_neutral, lyra_good):
jump vickygoodending
elif landon_good > max(landon_neutral, vicky_good, vicky_bad, lyra_good):
jump landongoodending
elif landon_neutral > max(landon_good, vicky_good, vicky_bad, lyra_good):
jump landonneutralending
elif landon_good > max(landon_good, vicky_good, vicky_bad, landon_neutral):
jump lyragoodending
else:
jump otherending
However, when I launch the project and test it by making choices I know can only go to one character's specific ending, it always jumps to "otherending". How do I fix that? Also, I'm extremely new to coding and have never used Ren'py prior and need to understand via the most simple of simplistic explanation. Thank you!
label end:
if vicky_bad > max(vicky_good, landon_good, landon_neutral, lyra_good):
jump vickybadending
elif vicky_good > max(vicky_bad, landon_good, landon_neutral, lyra_good):
jump vickygoodending
elif landon_good > max(landon_neutral, vicky_good, vicky_bad, lyra_good):
jump landongoodending
elif landon_neutral > max(landon_good, vicky_good, vicky_bad, lyra_good):
jump landonneutralending
elif landon_good > max(landon_good, vicky_good, vicky_bad, landon_neutral):
jump lyragoodending
else:
jump otherending
However, when I launch the project and test it by making choices I know can only go to one character's specific ending, it always jumps to "otherending". How do I fix that? Also, I'm extremely new to coding and have never used Ren'py prior and need to understand via the most simple of simplistic explanation. Thank you!
- erickcire95
- Regular
- Posts: 33
- Joined: Tue Dec 26, 2017 7:38 pm
- Contact:
Re: Playthrough does not account for point-based endings, jumps to "else"
Remember that the blocks of every "if", "elif" or "else" should have identation.
it should work with something like this:
if it still doesn't work, then check that you are properly adding points to the variables when needed, like
whenever it's needed
if it STILL doesn't work, then check the labels are defined right.
it should work with something like this:
Code: Select all
if vicky_bad > max(vicky_good, landon_good, landon_neutral, lyra_good):
jump vickybadending
elif vicky_good > max(vicky_bad, landon_good, landon_neutral, lyra_good):
jump vickygoodending
elif landon_good > max(landon_neutral, vicky_good, vicky_bad, lyra_good):
jump landongoodending
elif landon_neutral > max(landon_good, vicky_good, vicky_bad, lyra_good):
jump landonneutralending
elif landon_good > max(landon_good, vicky_good, vicky_bad, landon_neutral):
jump lyragoodending
else:
jump otherending
Code: Select all
$ vicky_bad += 1
if it STILL doesn't work, then check the labels are defined right.
Code: Select all
label vickybadending:
"Blah blah blah"
#write the vicky bad ending here
"BAD ENDING"
return
-
- Newbie
- Posts: 6
- Joined: Tue Jan 02, 2018 8:12 am
- Contact:
Re: Playthrough does not account for point-based endings, jumps to "else"
All of that was done and triple-checked prior to posting this. I just went and checked again and it's still not working, I even defined the points at the start label. It always just jumps to "else" :/
- 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: Playthrough does not account for point-based endings, jumps to "else"
max expects an iterable, not separate *args...
max( [ vicky_good, landon_good, landon_neutral, lyra_good ] )
max( [ vicky_good, landon_good, landon_neutral, lyra_good ] )
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
-
- Newbie
- Posts: 6
- Joined: Tue Jan 02, 2018 8:12 am
- Contact:
Re: Playthrough does not account for point-based endings, jumps to "else"
I'm sorry, what do those terms mean?
I added the brackets and spaces and it still jumps to else :/
I added the brackets and spaces and it still jumps to else :/
Re: Playthrough does not account for point-based endings, jumps to "else"
Nah, it will take arguments or an iterable. https://docs.python.org/2/library/functions.html#max
To OP, try debugging to see if the variables are in fact what you think they are. Simplest way is to print them in a say statement right before the if/else.
- erickcire95
- Regular
- Posts: 33
- Joined: Tue Dec 26, 2017 7:38 pm
- Contact:
Re: Playthrough does not account for point-based endings, jumps to "else"
Try doing what philat said.
Add a say statement to show the value of your variables right before the jump to endings.
Something like:
This way it will show the value of your variables before jumping to the ending.
Now, you should get five numbers, and one of those should be bigger than the rest in order to jump to a label other than "otherending". If you get some weird things here then you need to check again how you are setting the variables.
NOTE:
If the biggest value is shared by two or more variables, it will jump to "else". i.e:
if you get a message like:
"Your variables are: 3, 7, 2, 6, 7"
it will jump to else, since the biggest value (in this case, 7) appears more than once
By the way, I think you have a little mistake in your last "elif", it says "landon_good" but I think you meant "lyra_good", if you were testing this trying to get the lyra good ending then that's the reason why it didn't work
Add a say statement to show the value of your variables right before the jump to endings.
Something like:
Code: Select all
"Your variables are: [vicky_bad], [vicky_good], [landon_good], [landon_neutral], [lyra_good]"
if vicky_bad > max(vicky_good, landon_good, landon_neutral, lyra_good):
jump vickybadending
elif vicky_good > max(vicky_bad, landon_good, landon_neutral, lyra_good):
jump vickygoodending
elif landon_good > max(landon_neutral, vicky_good, vicky_bad, lyra_good):
jump landongoodending
elif landon_neutral > max(landon_good, vicky_good, vicky_bad, lyra_good):
jump landonneutralending
elif lyra_good > max(landon_good, vicky_good, vicky_bad, landon_neutral):
jump lyragoodending
else:
jump otherending
Now, you should get five numbers, and one of those should be bigger than the rest in order to jump to a label other than "otherending". If you get some weird things here then you need to check again how you are setting the variables.
NOTE:
If the biggest value is shared by two or more variables, it will jump to "else". i.e:
if you get a message like:
"Your variables are: 3, 7, 2, 6, 7"
it will jump to else, since the biggest value (in this case, 7) appears more than once
By the way, I think you have a little mistake in your last "elif", it says "landon_good" but I think you meant "lyra_good", if you were testing this trying to get the lyra good ending then that's the reason why it didn't work
-
- Newbie
- Posts: 6
- Joined: Tue Jan 02, 2018 8:12 am
- Contact:
Re: Playthrough does not account for point-based endings, jumps to "else"
Ooh, the lyra mistake was just on this forum post. The game is supposed to be a gift for someone and features our friend group, I changed the names for privacy reasons to post here. When I check the original script, the name is correct.
I ran the script by a friend of mine who studied compsci for a bit—apparently my syntax is correct, but for some reason all the variables are stuck at 1, and that's why it jumps to "else." (Upon removing "else" previously it would just jump to the first option.) However, she doesn't understand why that is. I really appreciate your guys' help so far!!!
I ran the script by a friend of mine who studied compsci for a bit—apparently my syntax is correct, but for some reason all the variables are stuck at 1, and that's why it jumps to "else." (Upon removing "else" previously it would just jump to the first option.) However, she doesn't understand why that is. I really appreciate your guys' help so far!!!
- erickcire95
- Regular
- Posts: 33
- Joined: Tue Dec 26, 2017 7:38 pm
- Contact:
Re: Playthrough does not account for point-based endings, jumps to "else"
How are you setting the variable changes? be sure that you are not missing the + symbol or placing it in a wrong position.lixiaolang wrote: ↑Fri Jan 12, 2018 6:13 am apparently my syntax is correct, but for some reason all the variables are stuck at 1, and that's why it jumps to "else."
This is correct:
$ lyra_good += 1
This won't add anything:
$ lyra_good =+1
The answer is, since none of the if\elif can be fulfilled, it just skips that part. Then continues to read the script from the next line. I assume that immediately after the if\elif you wrote the label of the first option.lixiaolang wrote: ↑Fri Jan 12, 2018 6:13 am (Upon removing "else" previously it would just jump to the first option.) However, she doesn't understand why that is.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot]