# How do I make something happen in increments.

Get help using Construct 2

### » Sat May 17, 2014 6:35 pm

How do I make something happen in increments.

So I have a global variable, set it to zero and each time you click the mouse button it adds 1 to the variable on the 5th click "pew pew" something happens. Do I then set the veritable back to zero and then count the clicks backup to 5 so "pew pew" something happens or can I say the 5th click the 10th click the 15th click and so on.

I want to do the same thing with scoring say 5000 you get a free man, 10,000 you get a free man.

Any ideas?
B
25
S
10
G
3
Posts: 154
Reputation: 2,843

### » Sat May 17, 2014 8:49 pm

You could do it that way or, you could use the Modulus operator (%). You can see more about it if you look it up but this is what you would use for your condition:

Use a System "Compare 2 Values" event and set the 2 values to the following
Value 1:
CurrentCount % 5
Value 2:
0

CurrentCount is the name of your variable and you will want it to start at 1 because 0 % anything is always equal to 0.
Last edited by FragFather on Tue May 20, 2014 2:33 pm, edited 1 time in total.
B
41
S
12
G
11
Posts: 331
Reputation: 7,767

### » Sun May 18, 2014 4:44 pm

I will this a try and read up on Modulus, thanks FragFather.
B
25
S
10
G
3
Posts: 154
Reputation: 2,843

### » Mon May 19, 2014 7:08 pm

Tried it but not working, so lets say I wanted to give a extra life every 100 points would I write it:

First Value: VarScore % 100
Comparison: = Equal to
Second Value: 0

VarScore is the name of the Score variable, and are you saying VarScore should start out as having a value of 1 and not 0?
B
25
S
10
G
3
Posts: 154
Reputation: 2,843

### » Tue May 20, 2014 5:49 am

Using this method for the score/new life will be much more difficult than the every Nth click event you mentioned in your first post. Scores rarely hit exactly on the value you earn a bonus for. You usually get it when your score is greater or equal to the necessary score. For this situation, I would suggest you set a LastBonus variable and check where Score >= LastBonus + 100.

I was suggesting the method again for the click iteration situation. In that case, the user will always click a 5th, 10th or 15th time. You can't skip from clicking 4 times to 8 times. The (VarScore % 100 = 0) means the score has to be an exact multiple of 100.

For the last question, yes. If the variable you are testing starts at 0, the Modulus will start as true so the user would get a new life immediately. There is however, a way around this by adding a condition that says score != 0.
B
41
S
12
G
11
Posts: 331
Reputation: 7,767

### » Tue May 20, 2014 1:25 pm

Thanks for the lesson, I learn a bit more every day one of these days I might even finish a project.
B
25
S
10
G
3
Posts: 154
Reputation: 2,843