Multi Flag Conditioned Events

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
vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Multi Flag Conditioned Events

#1 Post by vaanknight »

I was wondering... what's the correct syntax to check for several flags to advance to a certain event? Let's say I have this script for a single flag event:

Code: Select all

#To set the flag up...

    me "You have seen me now."
    $ flag_one = True

#And then to check for the flag...

    me "now, let me see if you have seen me before..."
    if flag_one:
        jump next_label
    me "Nope, you haven't seen me before... go back and look for me."
    jump look_for_me

label next_label:
    me "Yep, you've seen me before and now you can continue."
Now... let's say I have this instead... how do I set the if statement to ask for several flags?

Code: Select all

#To set the flag up...

    me "You have seen me now."
    $ flag_one = True

    me "You have seen me again."
    $ flag_two= True

    me "You have seen me yet again (aren't ya lucky?)."
    $ flag_three= True

#And then to check for the flag, what do I put in the if statement...?

    me "now, let me see if you have seen me three times before..."
    if (HOW ON EARTH DO I ASK FOR 3 FLAGS?):
        jump next_label
    me "Nope, you haven't seen me three times before... go back and look for me."
    jump look_for_me

label next_label:
    me "Yep, you've seen me three times before and now you can continue."
I hope I somehow made sense... xD
Image

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Multi Flag Conditioned Events

#2 Post by Jake »

vaanknight wrote:

Code: Select all

    if (HOW ON EARTH DO I ASK FOR 3 FLAGS?):
You can use the logical operators 'and' and 'or' to get a true/false value out of multiple flags. So if you want to require all three, then:

Code: Select all

  if flag_one and flag_two and flag_three:
if you want to require any one of three, then:

Code: Select all

  if flag_one or flag_two or flag_three:

... if you want more complex logic you may need to group operations with brackets, so - for example:

Code: Select all

  if flag_one and (flag_two or flag_three):
will check for flag_one and also either _two or _three, while

Code: Select all

  if (flag_one and flag_two) or flag_three:
will pass if:
- flag_one and flag_two are both True
- flag_three is True
- both of the above.
Server error: user 'Jake' not found

vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Re: Multi Flag Conditioned Events

#3 Post by vaanknight »

Ah, perfect! problem solved, thanks a bunch!
Image

Post Reply

Who is online

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