How do I Tie Two Conditions Together?

0 favourites
  • 6 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • In many programming languages, you can use if statements. In these if statements there can be multiple conditions such as if (x = y OR y = z OR x = a AND y = x). I am already aware you can use OR. Is there a way to use and in construct 2?

  • It's just two conditions together, when you create an event and then press C, these are AND. If you've already made an OR block, remove the OR, that is an AND block.

  • But I need an and AND an or block

  • Whatever you're trying to do can be done with sub events. The initial event is what has to be true and then the OR conditions are individual sub events. i.e.

    Y = true

    ---- X > 3 do this

    ---- X < 3 do this

    This is saying if Y= true AND x > 3, do this event, OR if Y=true and X < 3, do the second event.

    Or like I said above they can be individual events with bunched together conditions. If you're trying to do something specific and can't work out how then post what you're trying to do.

  • Additional. About 'if statements'.

    There are pure "IF statements' in c2. One is (by example) System > Compare two values. A pure logical condition that sets the condition true or not true. When true it runs its actions.

    Most conditions are merely 'pick conditions'. Example Sprite > Compare Instance variable.

    This will list all instances of a sprite that meet the condition in the 'picklist'. Actions addressed to that sprite will only work on its instances in the 'picklist'. This is not a pure 'IF statement', as you know them.

    Bring two of those conditions in 1 event, and the second conditions will start picking from the 'picklist' made with the first condition. Example:

    (Sprite) Is on screen <------ makes a picklist of all the instances of Sprite that are on screen.

    (Sprite) Is overlapping another object (Tilemap) <---- Starts picking from the previous picklist, or, starts with all Sprites that are on screen and filters those that dont overlap TIlemap out.

    At this point, the resulting picklist of the two conditions contains (besides the Tilemap) all instances of Sprite that are on screen AND overlap Tilemap. Actions addressed to Sprite will only work on those picked instances.

    So, most conditions are pick conditions. There is one situation where they fall back to being a 'logical condition', or as you call it an 'IF statement'. And that is when the resulting picklist is empty. When the picklist is empty, the condition is untrue, and non of the actions will run.

    All i wrote here is not really true, because still incomplete, it is the right direction in a nutshell.

    Please read this, it will bring light in the darkness.

    https://www.scirra.com/manual/75/how-events-work

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you so much! You really helped us out a lot!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)