# every 100 Coins = 1 life (mario bros)

Get help using Construct 2

### » Fri Feb 19, 2016 2:44 am

Hello

English

Hello good, I wanted to know how I can perform the command every 100 coins or points 1 life is added, if they could help me thanks and regards

Español

Hola buenas, queria saber como puedo realizar el comando de que cada 100 monedas o puntos se agregue 1 vida, si me podrian ayudar gracias y saludos

B
20
S
6
G
1
Posts: 51
Reputation: 1,869

### » Fri Feb 19, 2016 2:48 am

Condition
System - Compare two values: CoinsVariable = 100

Action
Set CoinsVariable to 0
B
60
S
30
G
134
Posts: 1,949
Reputation: 75,375

### » Fri Feb 19, 2016 10:30 am

I guess you already have a variable for coins. What you have to do now, is this: one way is to use modulo. I think that's the simplest, because you don't need any additional variables.
System|Compare two values: Coin%100 = 0 (and) Trigger once while true -> System|Add 1 to Life

(Assuming Coin is the variable for coins and Life for lifes)
https://www.dropbox.com/s/yyaxf6pw0emqt ... o.jpg?dl=0

Maybe you may want to add another condition: Coin /= 0, so 1 life isn't added on start when you have 0 coins.
https://www.dropbox.com/s/gyhd4vxhz3u6y ... 2.jpg?dl=0

What is modulo?
Modulo is actually the remain of dividing. In C2, it is represented with percent sign (%).
Example:
50%100 = 50 (50/100 = 0, 50 remains)
100%100 = 0 (100/100 = 1, 0 remains)
200%100 = 0 (200/100 = 2, 0 remains)
B
32
S
7
G
4
Posts: 408
Reputation: 4,616

### » Sat Feb 20, 2016 7:10 pm

Thank you very much friend, but finished before yesterday, a friend helped me a tutorial, but equal to I made something similar oosyrag.

-------------------------------------------------------------------------------------
Add variable global: variable number|Extras = 100

And In Add Event: System|Monedas = Extras | system add 1 life -->(compare variable: monedas = Extras)
-------------------------------------------------------------------------------------

and thereby completing 100 coins system adds 1 life and 100 extras, so to reach 200 coins 1 life and 100 extras, and so on is added: D Thanks alike, if it serves this would be great

Thank You Friends
Last edited by Totimundo on Sat Feb 20, 2016 7:20 pm, edited 1 time in total.
B
20
S
6
G
1
Posts: 51
Reputation: 1,869

### » Sat Feb 20, 2016 7:13 pm

See also, as one can reset a global variable, and no reset all?
B
20
S
6
G
1
Posts: 51
Reputation: 1,869

### » Sun Feb 21, 2016 10:17 pm

Totimundo wrote:See also, as one can reset a global variable, and no reset all?

I guess the only way to do that is System|Set value to 0 (or whatever you have at start).
B
32
S
7
G
4
Posts: 408
Reputation: 4,616

### » Mon Feb 22, 2016 6:34 pm

thank you friend grigrizljac and the others, greeting
B
20
S
6
G
1
Posts: 51
Reputation: 1,869