Variables exceeding their limit

quantumsheepquantumsheep Member Posts: 8,188
edited November -1 in Working with GS (Mac)
Hey all!

I'm wondering if I'm doing something wrong (probably am).

I'm using integer variables to control certain things - e.g. how many power-ups you can use.

I don't want the player to have more than four power ups. So I put in a rule 'If powerups is equal to, or greater, than 4, make the powerups =4"

It seems though that on occasion, and more and more frequently, the variables *do* go above 4 for example.

Is there a rock solid way of getting a variable to stop at a certain number?

Hope that's clear?

Cheers,

QS :)

Oh, and apologies for all the questions lately! I wouldn't ask if I wasn't honestly stuck!

Comments

  • SDMGSDMG Member Posts: 280
    my idea about a rock solid way :

    var_power_up = x;
    var_rock_solid = min(4, var_power_up);

    does it rock?
  • quantumsheepquantumsheep Member Posts: 8,188
    I don't get it :(
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Take a look at what causes your integer to increment when you gather a powerup. Add the condition in it that says if your power_up_count is < 4, then act as normal.
  • quantumsheepquantumsheep Member Posts: 8,188
    Funnily enough, I worked that out by myself would you believe! A little thought, and perhaps writing it out to try and explain it to someone else maybe kick starts my brain cell!

    Thanks for your input though!

    Cheers,

    QS
Sign In or Register to comment.