How do I Tie Two Conditions Together?

Get help using Construct 2

Post » Sun Jul 23, 2017 6:25 pm

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?
B
6
S
2
Posts: 7
Reputation: 466

Post » Sun Jul 23, 2017 6:44 pm

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.
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sun Jul 23, 2017 7:13 pm

But I need an and AND an or block
B
6
S
2
Posts: 7
Reputation: 466

Post » Sun Jul 23, 2017 7:20 pm

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.
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sun Jul 23, 2017 7:22 pm

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
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jul 23, 2017 8:42 pm

Thank you so much! You really helped us out a lot!
B
6
S
2
Posts: 7
Reputation: 466


Return to How do I....?

Who is online

Users browsing this forum: angryscientist and 26 guests