How do I make upgrades only trigger once, ever?

Get help using Construct 2

Post » Thu Nov 10, 2016 2:40 am

Image

In my game, the player will be able to purchase upgrades to objects on specific layouts that persist throughout the game. In this case, an item in the player's house increases the filling speed of their EXP bar. The codebox is a global object that keeps track of variables that are important such as what level the upgrade-able objects are at, and what bonuses to distribute. The upgrade itself works just fine, the problem is that it triggers lines 105 and 107 again every time the player changes to a different layout. So the +5 to mainbar_speed becomes +10 on changing layout, then +15, etc.

What am I doing wrong here? I assumed trigger once meant only once, but it seems to mean once on the current layout.
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Thu Nov 10, 2016 11:15 am

The "trigger once" condition prevents an event from activating multiple times once its other conditions are met.

For instance: If you have an event with the conditions "ObjectA is overlapping ObjectB" and "Trigger Once", it would trigger once when starts ObjectA overlapping with ObjectB, and then wait for them to stop overlapping to check again.


I'm afraid there's no event to have something happen once and then never again in the game, but it should be simple to achieve by various other means.

In your case, you could simply move the "Add 1 to mainbar_speed" to the events that set the object's level and charge the player money. This way, it'll add to the global variable at the moment you upgrade, and only then.
B
13
S
2
Posts: 19
Reputation: 768

Post » Thu Nov 10, 2016 12:43 pm

It does mean trigger once on the current layout. If you want it to trigger once ever you can block it out by using another variable as a condition and then set it to something else below the action. So on 104 if debugobject=1 and anothervariable=0 then do the action. On the action add 1 to speed and set anothervariable to 1. That way 104 can never be triggered again because global anothervariable will never be 0.
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Thu Nov 10, 2016 3:38 pm

Try using global variables as indicators and local storage to save the progress.
B
11
S
3
G
1
Posts: 34
Reputation: 872

Post » Thu Nov 10, 2016 4:16 pm

Thank you all for the suggestions! They were all very informative and helpful. :)
B
18
S
9
Posts: 103
Reputation: 1,817


Return to How do I....?

Who is online

Users browsing this forum: corporatedrone, Google [Bot] and 26 guests