# Check if a variable is dividable by 3

Discussion and feedback on Construct 2

### » Fri Oct 14, 2016 1:29 pm

Hey guys,

I got a math related question:
I have a variable witch keeps track of how many times the player goes to the main menu. I want to check if it is dividable by 3 and then do something like show an ad.

How can I achieve this?
B
32
S
9
G
7
Posts: 274
Reputation: 5,725

### » Fri Oct 14, 2016 1:45 pm

Check the number in the variable like this:
variable%3=0;
B
141
S
34
G
17
Posts: 1,561
Reputation: 21,065

### » Fri Oct 14, 2016 2:22 pm

glerikud wrote:Check the number in the variable like this:
variable%3=0;

Hey,

It does not seem to work.
I made it so whenever I clicked it would ad 1 point to the var, I added a debug txt object witch would show me the var points and I added your code like this:

System - Compare Variable - [Var Name] % 3 = 0 (And then I would change the position of an object)
B
32
S
9
G
7
Posts: 274
Reputation: 5,725

### » Fri Oct 14, 2016 3:38 pm

B
141
S
34
G
17
Posts: 1,561
Reputation: 21,065

### » Fri Oct 14, 2016 8:11 pm

Wow!
I didn't know you could compare two values! This helped me a lot, thanks!
B
32
S
9
G
7
Posts: 274
Reputation: 5,725

### » Sat Oct 15, 2016 10:35 am

TRMG wrote:Wow!
I didn't know you could compare two values! This helped me a lot, thanks!

You're welcome. Good luck to your project.
B
141
S
34
G
17
Posts: 1,561
Reputation: 21,065

### » Sat Oct 15, 2016 8:53 pm

glerikud wrote:
TRMG wrote:Wow!
I didn't know you could compare two values! This helped me a lot, thanks!

You're welcome. Good luck to your project.

<3 You to!
B
32
S
9
G
7
Posts: 274
Reputation: 5,725

### » Wed Oct 19, 2016 5:15 pm

glerikud wrote:
TRMG wrote:Wow!
I didn't know you could compare two values! This helped me a lot, thanks!

You're welcome. Good luck to your project.

Hi again,

I got another related question (if you don't mind...):
how would I do the same thing with a variable that would jump by 1,2 or 3 at a time?
I basically want this:
"If var X is equal to 10 or 11 or 12 then execute code"
I want it to happen every 10 units (10 or 11 or 12; 20 or 21 or 22... and so on) and the var would also go indefinitely (so I can't hard-code it)
Do you have any idea how to do this?

Also, if you don't have the time to help me with this I will start a new entry in the forum; I replied back because you knew already what I wanted and it is easier to explain =D
B
32
S
9
G
7
Posts: 274
Reputation: 5,725

### » Wed Oct 19, 2016 6:44 pm

Use event: Is Between Values and use these:

Lower bound: 0
Upper bound: 2
B
34
S
11
G
3
Posts: 191
Reputation: 3,678

### » Wed Oct 19, 2016 8:09 pm

gameglaux wrote:Use event: Is Between Values and use these:

Lower bound: 0
Upper bound: 2

Awesome!
Thank you!
B
32
S
9
G
7
Posts: 274
Reputation: 5,725