How do I trigger global variable has been changed?

Get help using Construct 2

Post » Sat Jun 20, 2015 6:06 pm

Help! How can I trigger that global wariable change its value? Example: bonus add 50 to GB1 if GB1 has change its value by picking bonus1 it will trigger. (Sorry for bad English).
B
15
S
5
G
1
Posts: 31
Reputation: 2,594

Post » Sat Jun 20, 2015 8:28 pm

You can add the event you want the variable to trigger to the same condition that change its value.
For instance, bonus add 50 to GB and do some other thing that you are expecting to happen every time GB value changes.

Or, if this is supposed to happen only once, you may try setting a initial value to GB, then set a condition that if GB is different from its initial value it will do whatever it is you want it to do.

Or moreover, you can work with two variables. GB and another variable to keep it's current value. Then if both GB and the second one doesn't have the same value you do whatever the function of GB is and by the end of it you set the other variable's value to the same value of GB.

There's actually a lot of ways to solve this, you should use that fits the best whatever it is you are trying to do.

I really hope this helps, if you need some further more assistance, please upload your .capx so we can have a better understanding of what you are trying to do.

:D
B
17
S
7
Posts: 277
Reputation: 2,514

Post » Sun Jun 21, 2015 5:56 pm

RayKi wrote:You can add the event you want the variable to trigger to the same condition that change its value.
For instance, bonus add 50 to GB and do some other thing that you are expecting to happen every time GB value changes.

Or, if this is supposed to happen only once, you may try setting a initial value to GB, then set a condition that if GB is different from its initial value it will do whatever it is you want it to do.

Or moreover, you can work with two variables. GB and another variable to keep it's current value. Then if both GB and the second one doesn't have the same value you do whatever the function of GB is and by the end of it you set the other variable's value to the same value of GB.

There's actually a lot of ways to solve this, you should use that fits the best whatever it is you are trying to do.

I really hope this helps, if you need some further more assistance, please upload your .capx so we can have a better understanding of what you are trying to do.

:D


That was helpfull, thanks :) ! But I need .capx :oops: . Let me explain what I want to do: I want to catch cheaters on cheating with this-> if clobal variable "money 1" change , but player sprite does not pick any money, system will kill player. This event need triger that global variable changed without picking money. (Sorry for REALLY BAD english).
B
15
S
5
G
1
Posts: 31
Reputation: 2,594

Post » Sun Jun 21, 2015 6:16 pm

If you want to catch cheaters it would be helpfull to know how they would be able to cheat.. :)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jun 21, 2015 6:49 pm

Ok I think this might work then.

Create a variable that will have the same value as GB, whenever GB and this variable have different values is because GB changed.

Then all you need to do it check if this change was made legally by the game rules or not. To check this, I created kind of a "password" inside the coin. So every time GB value changes we check that password, if it's incorrect the player is destroyed.

Here, see if it works:
https://dl.dropboxusercontent.com/u/183 ... tIdea.capx
B
17
S
7
Posts: 277
Reputation: 2,514


Return to How do I....?

Who is online

Users browsing this forum: mindragon73, Yahoo [Bot] and 16 guests