Turn a Negative Varible to zero

0 favourites
  • 6 posts
From the Asset Store
“Zero Numbers” is a logic game. Game with Source-Code (Construct 3 / .c3p) + HTML5 Exported
  • I have a system where you hit a button and gives a certain money value,

    that's great for adding to your bank, but I also want to have a set price for a car.

    And I have the value decrease as you make more money. But You very often make more money than the value of the car. But then the number goes way below zero into negatives.

    And it won't let me fire an event on when the car value equals zero. I tried compare variables, but the less than sing seems to not work or understand.IDK

  • Or max(value, 0)

  • It stops at zero! I thought I would be stuck forever.

    Just tested and fired my action at zero worked like a charm.

    I used max(carPrice),0).

    I would of used clamp, but I wasn't to sure how to use it.

    Thank you Both!

  • There is also min(price, 100) if you want to limit the maximum price.

    And clamp(price, 0, 100) to do both.

    Read about system expressions, you may find lots of useful things there:

    construct.net/en/make-games/manuals/construct-3/system-reference/system-expressions

  • Ok this might be along the same lines, but now I want to add a "boost" button

    to the moneyMaking variable part.

    So like so many click makes a certain amount of $ and the boost would x2 or something. But the boost will also have a cost. My project is slowly turning into a simple economy game.

    so i start with the

    boost being another cost item

    and

    when it hits zero(after paid)

    then it adds a multiplier to the moneyMaker so set moneymMaker to moneymaker x2; something like that. So I kind of answered my own question this time.

    This is sort of how my mind figures this programming out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, so now I have a new issue I didn't think of before this.

    lets say the moneyMaker = 16,000 and the carPrice is 14,500

    Yes it goes to zero which is what I asked for but I see that what I really need now is only take the amount needed. The monies is being distributed to different places of the players choosing. But the chance that the money made being the exact amount need for the car is very slim. It will be like 500,

    250, 50, 1500, increments. So basically you save up for you items you want. But by adding it to the amount of the car until it's 0. Than you get the car.

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