How do I test if a value is a multiple of

Get help using Construct 2

Post » Wed Mar 16, 2016 8:48 am

So, if I wanted an event that worked only if the value of a variable was a multiple of 4 or 8, say, or even test for only odd or even numbers?
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,282

Post » Wed Mar 16, 2016 9:01 am

multiple of 4: var%4=0
for multiple of 8: var%8=0
even: var%2=0
odd: var%2=1

% means MOD
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Mar 16, 2016 9:03 am

dont forget a condition for zero
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Mar 16, 2016 11:17 am

99Instances2Go wrote:multiple of 4: var%4=0
for multiple of 8: var%8=0
even: var%2=0
odd: var%2=1

% means MOD

Works perfectly, thankyou!!
B
41
S
12
G
14
Posts: 1,122
Reputation: 11,282


Return to How do I....?

Who is online

Users browsing this forum: gameba, Yahoo [Bot] and 5 guests