if and elif with more than two options?

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
Calissa Leigh
Regular
Posts: 54
Joined: Wed Apr 11, 2012 11:04 am
Completed: No games, just books. :)
Projects: Murder Mystery 1
Organization: Arcato Publishing
Location: Among the people, and Cajuns
Contact:

if and elif with more than two options?

#1 Post by Calissa Leigh » Mon Apr 16, 2012 7:35 pm

Hello,

I was wondering how to word something. I would like to be able to have more than one option when reaching a "if" and elif" place.

So say there's a chapter change and it would trigger a cut scene. Depending on which guy ended up with the most points, that person's cut scene would be triggered.

Is it possible to go

if Bobpoints > Carlpoints, Tompoints, Harrypoints:

show... yada yada

elif Carlpoints > Tompoints, Bobpoints, Harrypoints:

show.... yadada

else:



And to do elif for all four if they aren't?

Hope that makes sense. :) I want to use if statements for more than two options if possible.

User avatar
sciencewarrior
Veteran
Posts: 356
Joined: Tue Aug 12, 2008 12:02 pm
Projects: Valentine Square (writer) Spiral Destiny (programmer)
Location: The treacherous Brazilian Rainforest
Contact:

Re: if and elif with more than two options?

#2 Post by sciencewarrior » Mon Apr 16, 2012 8:18 pm

You can have as many elif blocks as you want. The first one in which the condition is true will be executed.
BTW this works:
if Bobpoints > max(Carlpoints, Tompoints, Harrypoints):
Keep your script in your Dropbox folder.
It allows you to share files with your team, keeps backups of previous versions, and is ridiculously easy to use.

Calissa Leigh
Regular
Posts: 54
Joined: Wed Apr 11, 2012 11:04 am
Completed: No games, just books. :)
Projects: Murder Mystery 1
Organization: Arcato Publishing
Location: Among the people, and Cajuns
Contact:

Re: if and elif with more than two options?

#3 Post by Calissa Leigh » Mon Apr 16, 2012 8:28 pm

Thanks again! That's awesome. :)

Post Reply

Who is online

Users browsing this forum: No registered users