Page 1 of 1

Multi Flag Conditioned Events

Posted: Thu Aug 12, 2010 11:24 am
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

Re: Multi Flag Conditioned Events

Posted: Thu Aug 12, 2010 11:34 am
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.

Re: Multi Flag Conditioned Events

Posted: Thu Aug 12, 2010 11:37 am
by vaanknight
Ah, perfect! problem solved, thanks a bunch!