Attribute range

StrykerStryker Member Posts: 40
edited November -1 in Working with GS (Mac)
Hey,

I have a atribute that +/-1 every time a button is pushed. Whats the best way to keep that attribute from going above 21 and below 0.

Thanks

Comments

  • iDeveloperziDeveloperz Member Posts: 1,169
    I wouldn't say it's the best way but.

    If attribute ≥ 21 change attribute to 20.
    and...
    If attribute ≤ 0 change attribute to 1.

    Maybe. :)
  • StrykerStryker Member Posts: 40
    Thanks, thats what i thought but i wanted to see if there was a more efficient way. Like a setting on the actual attribute or something...
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Use the max() and min() functions in the expression editor to set limits.
  • StrykerStryker Member Posts: 40
    Aha, thats what i was hoping for. Is there a wiki page that enplanes all those expressions?
  • StrykerStryker Member Posts: 40
    Hmm... How exactly would I apply the Min/Max functions?

    ifTouch is Pressed then
    game.Run +random(1,3)max(20)

    Does that look right?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Almost. Like this:

    If Touch is pressed then
    Change attribute: game.Run to: min(game.Run + random(1,3),20)
Sign In or Register to comment.