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

Get help using Construct 2

Post » Thu Dec 22, 2016 1:26 pm

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?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Thu Dec 22, 2016 1:51 pm

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
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Thu Dec 22, 2016 2:33 pm

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
B
16
S
7
G
3
Posts: 395
Reputation: 3,693

Post » Thu Dec 22, 2016 11:45 pm

mekonbekon wrote: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?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253


Return to How do I....?

Who is online

Users browsing this forum: davidbox, Mayfly, Yahoo [Bot] and 4 guests