Trigger if number is a multiple of 4 exactly (modulo?)

0 favourites
  • 4 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • I want to display a button if a number is exactly a multiple of 4+1 (after the initial 8), so every time the number is 9, 13, 17, 21, 25, etc, but not if it's between those, so I don't want it to display if the number is 10-12 inclusive, 14-16 inclusive, 18-20 inclusive, I'm sure I can do this with mod, but not quite sure how to input this in the expression editor?

  • Example from 8 to 100 put into an array.

    System| For i from 8 to 100 -> Array| push back loopindex+1 on X axis

    System| loopindex%4

    Edit:

    If you want it the the other way round:

    Array| For each X element -> do something.

    Array| Array.CurValue>8

    Array|(Array.CurValue-1)%4=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A slightly simpler solution without using arrays:

    Use System condition|Compare two values:

    If (value-1%4) is equal to 0

    and value > 8

    Set button visible

    else Set button invisible

  • A slightly simpler solution without using arrays:

    Use System condition|Compare two values:

    If (value-1%4) is equal to 0

    and value > 8

    Set button visible

    else Set button invisible

    Hmm, I tried

    Inventory.Width-1%4 = 0

    But it only seems to work when there's 1 item in the array (after having 0 items in the array) but not again on 5 items?

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