Special Condition, at least three among 8

0 favourites
  • 4 posts
From the Asset Store
A collection of various soldier character sprites for creating a 2D platformer or sidescroller game
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Couldn't you just add them?

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

  • 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.

  • > 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

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)