How do I check if variable is equal to multiple numbers

Get help using Construct 2

Post » 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
25
S
10
G
1
Posts: 154
Reputation: 2,687

Post » Thu Aug 25, 2016 10:49 pm

& = and
| = or

0 = false
1 = true

condition is true .. actions run
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Aug 25, 2016 10:52 pm

Thanks! It really should say that instead of 'return' imo. Problem solved.
B
25
S
10
G
1
Posts: 154
Reputation: 2,687

Post » 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
67
S
37
G
13
Posts: 241
Reputation: 12,760

Post » 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.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » 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
67
S
37
G
13
Posts: 241
Reputation: 12,760

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 42 guests