OR condition

Get help using Construct 2

Post » Wed May 08, 2013 2:34 am

I want a Condition to check if a variable = 1 OR 5 OR 8 OR 9. I will have about 16 of these conditions, each checking for 3-4 values that vary in each condition... Any Ideas how to do this without writing 4 separate conditions for that one question? (I was thinking there was something like this:

If Var1=1,
OR,
If Var1=5,
OR,
If Var1=8,
OR,
If Var1=9 -> Do Expression
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Wed May 08, 2013 3:23 am

I don't know if you know this but you can set any block of conditions to be an "or" block instead of the default "and" block. Just right click the block (not the event) and click "set as or block" or something and if any of the events in there are true, it will do the action.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Wed May 08, 2013 3:58 am

If you add "|" with strings or variables inside of textbox, it won't work.

You should use C2 event design like adding OR block.

https://dl.dropboxusercontent.com/u/76227787/ORevent.capx
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Wed May 08, 2013 5:44 am

Thank you for the OR lesson! I missed that update...   (I was out of touch for about a year, so I missed a bunch of changes.)   That OR box will fix my problem.
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Wed May 08, 2013 6:47 am

There are other ways to do such comparisons. Here, I modified Joannesalfa capx to show the use of the logical OR operator (the |), and an alternative method using a function.

OR blocks are definately easier to read... although I hate the fact that you can't combine AND and OR in a single block.
B
45
S
16
G
18
Posts: 845
Reputation: 13,673


Return to How do I....?

Who is online

Users browsing this forum: Braus, RickUSBstick, Yura G and 19 guests