Playthrough does not account for point-based endings, jumps to "else"

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
lixiaolang
Newbie
Posts: 6
Joined: Tue Jan 02, 2018 8:12 am
Contact:

Playthrough does not account for point-based endings, jumps to "else"

#1 Post by lixiaolang »

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!

User avatar
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"

#2 Post by erickcire95 »

Remember that the blocks of every "if", "elif" or "else" should have identation.

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
if it still doesn't work, then check that you are properly adding points to the variables when needed, like

Code: Select all

$ vicky_bad += 1
whenever it's needed

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

lixiaolang
Newbie
Posts: 6
Joined: Tue Jan 02, 2018 8:12 am
Contact:

Re: Playthrough does not account for point-based endings, jumps to "else"

#3 Post by lixiaolang »

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" :/

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: Playthrough does not account for point-based endings, jumps to "else"

#4 Post by Remix »

max expects an iterable, not separate *args...

max( [ vicky_good, landon_good, landon_neutral, lyra_good ] )
Frameworks & Scriptlets:

lixiaolang
Newbie
Posts: 6
Joined: Tue Jan 02, 2018 8:12 am
Contact:

Re: Playthrough does not account for point-based endings, jumps to "else"

#5 Post by lixiaolang »

I'm sorry, what do those terms mean?

I added the brackets and spaces and it still jumps to else :/

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Playthrough does not account for point-based endings, jumps to "else"

#6 Post by philat »

Remix wrote: Thu Jan 11, 2018 8:19 am max expects an iterable, not separate *args...

max( [ vicky_good, landon_good, landon_neutral, lyra_good ] )
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.

User avatar
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"

#7 Post by erickcire95 »

Try doing what philat said.
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
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

lixiaolang
Newbie
Posts: 6
Joined: Tue Jan 02, 2018 8:12 am
Contact:

Re: Playthrough does not account for point-based endings, jumps to "else"

#8 Post by lixiaolang »

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!!!

User avatar
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"

#9 Post by erickcire95 »

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."
How are you setting the variable changes? be sure that you are not missing the + symbol or placing it in a wrong position.

This is correct:
$ lyra_good += 1

This won't add anything:
$ lyra_good =+1
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.
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.

Post Reply

Who is online

Users browsing this forum: Google [Bot]