Stop a global variable from being higher/lower than another

0 favourites
  • 4 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.
  • Hey guys, thanks for the beautiful and quick help so far.

    My question this time is;

    How do I stop a global variable from going over/under another global variable?

    Say I have two global variables, one that stores the amount of missiles I have (Missile Ammo). And another that holds the maximum number of missiles I can hold (Maximum Missiles).

    I have a UI with a text box set to make the text show the Missile Ammo variable.

    How do I make it so that Missile Ammo doesn't go over Maximum Missiles (say MM is 10, how do I make Missile Ammo not go over that value?)

    Also for my health global variable, I need to make it so that once it hits zero, it doesn't go into negatives.

    Any help? I hope this is understandable.

    Thanks for any suggestions and/or screenshots!

  • Something like:

    In the event where you add to your ammo add a subevent if ammo>MM set ammo: MM

    Same applies to the health

    in the event where you subtract from the health add a subevent health<0 set health:0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another method. Hope it helps.

  • Thanks guy, helped a lot! Sorry for the slow reply.

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