How do I trigger global variable has been changed?

0 favourites
  • 5 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • 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).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

    That was helpfull, thanks . 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).

  • If you want to catch cheaters it would be helpfull to know how they would be able to cheat..

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)