# How do I create repeatable upgrades?

Get help using Construct 2

### » Mon Nov 07, 2016 5:29 am

Hello, I've got a weird logic quirk that you folks can surely help me unravel. I want my game to have certain upgrades be repeatedly buyable for a number of ranks. This seemed like it'd be easy, but it's proving to be pretty tricky.

The way I've got this set up, what I expected to happen is: when the player clicks the button, if var_isbought is 0 it does the first upgrade and then sets it to 1, and stops. What I figured is that it would only perform the action that is true when the player first clicks the button, but it turns out that's not the case. Instead, it continues to the second upgrade and makes that change as well. How do I make it work like I intend for it to?
B
18
S
9
Posts: 103
Reputation: 1,817

### » Mon Nov 07, 2016 6:41 am

Reverse the sequence or use OR logic word.
B
22
S
3
Posts: 74
Reputation: 1,515

### » Mon Nov 07, 2016 6:47 am

Oh, interesting! I reversed the order of the two upgrade actions and now it works just fine. I guess order of operations is more important than I thought. Thank you!
B
18
S
9
Posts: 103
Reputation: 1,817

### » Mon Nov 07, 2016 10:11 am

Events are read from top to bottom.
Events are executed when all actions are true.

The events in your original sequence check if the player has enough money and if the object is bought.
In the first event, the player has money, and the object is not purchased. There "is_bought" is set to 1.

Second event, the player has money and the object is NOW purchased (in the same tick). So the upgrade is completed as well.

In order to "do the pause" as you intend, your second event requires to have a "Else" system condition.
This way, it would only execute one or the other event, and indeed the behaving of those events would equal what you expected.

Reverting events here will work, but is only a band aid that can go wrong if you were to attempt to add more upgrades later.
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
311
S
128
G
101
Posts: 7,416
Reputation: 75,228

### » Mon Nov 07, 2016 6:16 pm

Ahh, thank you for the explanation! That's a big help, I appreciate it.
B
18
S
9
Posts: 103
Reputation: 1,817