# Stacks of variables

Get help using Construct 2

### » Mon Feb 17, 2014 7:35 pm

Hi,

I am wondering how to write a condition: for each 10 score (score is a global variable) add 1 life.
How i write for each stack of 10 in the condition?

Basically the player earns points and i want to give him a bonus life when he reaches 10 points, 20, 30, 40..

Thanks!
B
14
S
4
G
1
Posts: 241
Reputation: 1,749

### » Mon Feb 17, 2014 8:06 pm

B
72
S
22
G
288
Posts: 3,862
Reputation: 158,460

### » Mon Feb 17, 2014 9:12 pm

I'm not sure it this works in C2, but everytime you add score, I would try a comparison between two values, score%10 and 0, if true add a life. score%10 returns the rest of the equation, so if score is a multiple of 10 it adds a life.

@blackhornet, this solution would end up giving the player, 1 life, then 2, then 3 and so on if he doesn't subtract 10 from score.

You can also use blackhornet's solution together with a 'hidden score', everytime it reachs 10, add a life and subtract 10 from it.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

### » Mon Feb 17, 2014 10:01 pm

True, I didn't read closely enough. Here's a sample of the working solution:
LifeScoring.capx
B
72
S
22
G
288
Posts: 3,862
Reputation: 158,460

### » Tue Feb 18, 2014 3:12 pm

thank you :)
B
14
S
4
G
1
Posts: 241
Reputation: 1,749