Multiple AND conditions?

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
tcassat
Regular
Posts: 33
Joined: Tue Oct 03, 2017 7:32 pm
Contact:

Multiple AND conditions?

#1 Post by tcassat »

Hello.

Is it possible to use multiple AND conditions on the same line? I would like an option to appear in a menu if three conditions were met: x >3, y is true and z is false:

It works with two conditions:

menu:
"Option A" if x>3 and y

But if I need another "and", things will not work out.

menu:
"Option A" if x>3 and y and not z


Note that I need to write everything on the same line because it is a menu option. Can you use multiple "and" and "or" or do I have to do it any other way?

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Multiple AND conditions?

#2 Post by RicharDann »

Yes, using multiple conditions that way should work. Are you sure that you're using the correct syntax?

Code: Select all

    menu:
        "Option A" if x > 3 and y and not z:
            "You picked A"
The most important step is always the next one.

tcassat
Regular
Posts: 33
Joined: Tue Oct 03, 2017 7:32 pm
Contact:

Re: Multiple AND conditions?

#3 Post by tcassat »

Yes, it worked, I had made a ridiculous mistake in the name of the variable (it was not as simple as "y"). I think the moderator can delete this topic!

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: Multiple AND conditions?

#4 Post by Remix »

Just for info, you can use all( list of tests ) and/or any( list of tests ) in a menu...

Code: Select all

    menu:
        "ok 1" if all( [ True, 1, len("a") ] ):
            "..."
        "ok 2" if any( [ True, 0, len("") ] ):
            "..."
        "bad 1" if all( [ False, 1, len("a") ] ):
            "..."
        "bad 2" if any( [ False, 0, len("") ] ):
            "..."
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Bing [Bot]