# How do I Create Condition "OR" and "AND" altogether

Get help using Construct 2

### » Tue Dec 16, 2014 2:23 am

I want to make conditions like this:
Condition1 or (condition2 and condition3)

If I use or block, all the three conditions become like this
Condition1 or condition2 or condition3

How to do this?

Thank you
B
10
S
5
Posts: 220
Reputation: 1,464

### » Tue Dec 16, 2014 3:11 am

LocalVariable = 0

If Condition2 and Condition3, set LocalVariable to 1

If LocalVariable =1 or Condition1, do something....

- or -

If Condition2 and Condition3, set LocalVariable to 1

If Condition1, set LocalVariable to 1

If LocalVariable = 1, do something....

They're not particularly eye pleasing but they'll do the job.
Learning other engines, but C2 still rocks.
B
80
S
22
G
96
Posts: 2,464
Reputation: 58,320

### » Tue Dec 16, 2014 5:15 am

you can compare two values in the System condition, and then put something like this for the first value:
( a=1 | (b=2 & c=3) ) ? 1:0
equals
1 (for the second value)

the ? checks if it is true, if so, uses value of 1, otherwise if it is false uses a value of 0.
This value then gets compared with the value you put in the second input box.
B
53
S
24
G
70
Posts: 1,200
Reputation: 41,428

### » Tue Dec 16, 2014 9:59 am

@Prominent has given the expert, non-event sheet slave, answer! I need to read some programming books!
Learning other engines, but C2 still rocks.
B
80
S
22
G
96
Posts: 2,464
Reputation: 58,320

### » Tue Dec 16, 2014 10:51 am

Prominent & Colludium, thank you for your response.
After trying to understand your answers, I come up with this:
I create an event, check condition1 and then I make sub event to cek condition 2 or condition 3.
B
10
S
5
Posts: 220
Reputation: 1,464

### » Tue Dec 16, 2014 3:56 pm

@Prominent The ternary part is not needed. The expression (a=1 | (b=2 & c=3)) already gives a value of 1 (true) or 0 (false).
B
81
S
33
G
27
Posts: 1,029
Reputation: 21,143

### » Tue Dec 16, 2014 5:37 pm

@Magistross Ah! good point, thanks man!
B
53
S
24
G
70
Posts: 1,200
Reputation: 41,428

Return to How do I....?

### Who is online

Users browsing this forum: ChenBr, irina and 6 guests