# Special Condition, at least three among 8

Get help using Construct 2

### » Thu Feb 13, 2014 12:59 pm

I have 8 global variables. All binary values.

The result of an 'IF' depends on if at least 3 of these 8 variables had a value of '1' instead of zero.

But, I can only made AND or OR blocks, so...

How to solve this?
B
17
S
4
G
1
Posts: 105
Reputation: 1,874

### » Thu Feb 13, 2014 1:17 pm

Var1+Var2+Var3+Var4+Var5+Var6+Var7+Var8 is greater or equal to 3
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Thu Feb 13, 2014 3:59 pm

[QUOTE=LittleStain] Couldn't you just add them?

Var1+Var2+Var3+Var4+Var5+Var6+Var7+Var8 is greater or equal to 3[/QUOTE]

Very nice! That is probably the best solution.

@Heptagono, since you have booleans, you could either change them to numbers with 0 and 1, or you can use the ternary operator, `?`.

Ex: (var1)1:0
That says if var1 is true, return 1. And if var1 is false, then return 0.danialgoodwin2014-02-13 16:03:05
B
20
S
4
G
1
Posts: 185
Reputation: 2,563

### » Thu Feb 20, 2014 9:30 am

danialgoodwin wrote:[QUOTE=LittleStain] Couldn't you just add them?

Var1+Var2+Var3+Var4+Var5+Var6+Var7+Var8 is greater or equal to 3

Very nice! That is probably the best solution.

@Heptagono, since you have booleans, you could either change them to numbers with 0 and 1, or you can use the ternary operator, `?`.

Ex: (var1)1:0
That says if var1 is true, return 1. And if var1 is false, then return 0.danialgoodwin2014-02-13 16:03:05[/quote]

Hey, good solution. I've just made a table of truth with all the posible combinations. After that it's just a looooong serie of conditions. If (1,2,3) then action, If (1,2,4) then action...About 15 groups like this.
B
17
S
4
G
1
Posts: 105
Reputation: 1,874