If, elif points and lots of multiple love interests

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
User avatar
bunny-gypsy
Regular
Posts: 61
Joined: Mon Aug 01, 2011 9:48 am
Contact:

If, elif points and lots of multiple love interests

#1 Post by bunny-gypsy »

Sorry if this has been asked before, and I read the How to Make a Simple Otome tutorial and the Ren'py Quickstart tutorial, but
I'm a little confused. The Otome tutorial is really great, since the programming stuff on Ren'py wiki is a bit confusing to me.

I'm doing a simple Halloween Otome (it's my first Ren'py VN) and I'm going to use relationship points like the Otome tutorial.
I have 8 love interests (who you get points with by talking or giving gifts).

The tutorial says for the endings, you type, for example:
(Excuse my terrible spacing, just wanted to quickly show examples)

Code: Select all

if brandonpoints>chrispoints:
               call brandonending

           elif chrispoints>brandonpoints:
               call chrisending 
and so on...

But what happens if you have lots of multiple love interests?
Do you keep saying "if" and "elif" for every one of the different love interests?

Code: Select all

                  if mummypoints>zombiepoints:
                        call mummyending
 
                 elif mummypoints>werewolfpoints:
                         call mummyending

                 elif mummypoints>fishboypoints:
                         call mummyending
                  #etc....

             #And then do this for every love interest?
                        if zombiepoints>fishboypoints:
                           call zombieending       

                        elif zombiepoints>werewolfpoints:
                            call zombieending
 
Is there a more streamlined way to do this, or should I figure what their total points are and use that, like:

Code: Select all

               if zombiepoints >= 10:
                   call zombieending
Trying out different things and learning Ren'py and Python programming. =)

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: If, elif points and lots of multiple love interests

#2 Post by AxemRed »

Code: Select all

if mummypoints > max(zombiepoints, werewolfpoints, fishboypoints):
ps: Make sure you don't forget to handle the case where all points are equal.

User avatar
bunny-gypsy
Regular
Posts: 61
Joined: Mon Aug 01, 2011 9:48 am
Contact:

Re: If, elif points and lots of multiple love interests

#3 Post by bunny-gypsy »

AxemRed wrote:

Code: Select all

if mummypoints > max(zombiepoints, werewolfpoints, fishboypoints):
ps: Make sure you don't forget to handle the case where all points are equal.
Ooh, that looks like what I'm looking for! :) Thank you very much. Just to verify, "max" means "maximum", yes?

So, for equal cases, it would look like this?:

Code: Select all

                         if mummypoints == max(zombiepoints, werewolfpoints, fishboypoints):
                                call mummyending

              #And then do this for every love interest?
                        if zombiepoints == max(mummypoints, werewolfpoints, fishboypoints):
                                call zombieending
                       #etc...
Trying out different things and learning Ren'py and Python programming. =)

AxemRed
Veteran
Posts: 482
Joined: Sun Jan 09, 2011 7:10 am
Contact:

Re: If, elif points and lots of multiple love interests

#4 Post by AxemRed »

Yes, max is maximum.

You can write the whole condition in one big if/else chain.

Code: Select all

if mummypoints > max(zombiepoints, werewolfpoints, fishboypoints):
    call mummyending
elif zombiepoints > max(mummypoints, werewolfpoints, fishboypoints):
    call zombieending
else:
    call neutralending

User avatar
bunny-gypsy
Regular
Posts: 61
Joined: Mon Aug 01, 2011 9:48 am
Contact:

Re: If, elif points and lots of multiple love interests

#5 Post by bunny-gypsy »

Oh, wow! That looks very clean and simple. =3 Thanks, AxemRed!

I'm finding that I am loving the coding when I can actually understand it.... XD
Trying out different things and learning Ren'py and Python programming. =)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Syrale