# How do I check if variable is equal to multiple numbers

Get help using Construct 2

### » Thu Aug 25, 2016 10:45 pm

I can't seem to wrap my head around what 'They return 1 if the comparison is true or 0 if false.' means. Can you please elaborate for me? I'm referring to the article.
B
30
S
12
G
1
Posts: 167
Reputation: 3,038

### » Thu Aug 25, 2016 10:49 pm

& = and
| = or

0 = false
1 = true

condition is true .. actions run
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Thu Aug 25, 2016 10:52 pm

Thanks! It really should say that instead of 'return' imo. Problem solved.
B
30
S
12
G
1
Posts: 167
Reputation: 3,038

### » Tue Sep 19, 2017 3:44 am

99Instances2Go wrote:& = and
| = or

0 = false
1 = true

condition is true .. actions run

Thanks I didn't know '&' and '|' could be used to compare more than 1 value at once.

I had a similar problem, I was using 'not equal' to compare.
I tried 'make or block' and 'value1|value2'.

The problem was the events were always triggered.
I couldn't figure out why, I even restarted C2 to make sure I didn't find a bug.

if value1 is not equal to apple.
or
if value1 is not equal to orange.

What was happening is if one isn't true the other one will be.
If value1 is apple, orange, or strawberry it will still trigger because at least one statement will always be true.
I thought about using & but a variable can't be two values at once.
I simply changed 'not equal' to 'equal' to make it work, and reorganized some of the events.

Is there any way to compare a variable to more than one value using 'not equal' that doesn't always trigger?
I couldn't think of a way. It would be useful to know if it were possible.
Last edited by Unconnected on Tue Sep 19, 2017 6:28 pm, edited 1 time in total.
B
80
S
41
G
13
Posts: 257
Reputation: 13,511

### » Tue Sep 19, 2017 3:57 am

AND is correct. If the value is not an apple AND the value is not an orange, then it must be a strawberry.
B
71
S
22
G
288
Posts: 3,858
Reputation: 158,422

### » Tue Sep 19, 2017 7:18 pm

I tried &, | and 'make or block' and it always triggers no matter the value I set it to.

I just think 'not equal to' can't be used to compare more than 1 value.
I was only curious about this.
'Equal to' with an 'Else' works similar enough.
B
80
S
41
G
13
Posts: 257
Reputation: 13,511

### » Sat Dec 16, 2017 8:25 pm

I know what you want!

Example: if selected a,b,c,d action for all

use right mouse button to the 1st and second condition and make or

Example:
B
12
S
2
Posts: 29
Reputation: 682

Previous

Return to How do I....?

### Who is online

Users browsing this forum: No registered users and 5 guests