max integer (item 999).

powkiepowkie Member Posts: 63
edited June 2012 in Working with GS (Mac)
Hi, so I've been stuck for a while and need some support :). I have an item that can stack up to 999. The thing is i can't seem to get the integer to be max 999 and not go further. Been trying stuff like constrain attribute game.item min(0),max(999) and similar but the it get stuck at either 0 or 999.

Anyone have a nice solution for this? To get the integer to understand that 999 is max so it won't go over 999. Same for 0, that 0 is the lowest number.

Thanks in advance!

Best Answer

  • Benjamin_m5Benjamin_m5 Posts: 646
    Accepted Answer
    the difference is that you now have -1999 before you used +1999 :)
    ---
    Benjamin

Answers

  • powkiepowkie Member Posts: 63
    i think this should work for you

    max(0,min(game.attribute+1,999))

    cheers
    Didn't work :( It's suppose to be an item that you can buy a maximum of 999, and as lowest you can have 0, tried the script above but it where still possible to go over 999 and below 0 :/
  • powkiepowkie Member Posts: 63
    edited June 2012
    it works, i tested it.
    you must be adding it wrong.

    post a screenshot of your rules and ill take a look.

    also please try and not reject answers so fast. You have to account for your errors.
    the next person that sees this thread may not try a working answer because you rejected it ;)


    cheers
    My bad! Well let me explain:

    Rule:

    Actor receives event - touch - pressed
    Attribute game.howmanyitems is 1 or greater then 1.

    Change attribute to:
    game.howmanyitems to: game.howmanyitems-1

    Change attribute game.useitem to 1

    New rule:

    Attribute game.howmanyitems is 0

    Change attribute self.color.alpha to: 0.3

    Otherwise 1.

    I tried to add your line in:
    game.howmanyitems to: max(0,min(game.howmanyitems+1,999)) but it did not work, let me know if i did anything wrong :)

    Thanks!
  • powkiepowkie Member Posts: 63
    no you need to use max(0,min(game.howmanyitems+1,999)) in YOUR expression

    Actor receives event - touch - pressed
    Attribute game.howmanyitems is 1 or greater then 1.

    Change attribute to:
    game.howmanyitems to: max(0,min(game.howmanyitems-1,999))

    I have no clue what i did different this time but now it works. Thanks again man!!!
  • powkiepowkie Member Posts: 63
    the difference is that you now have -1999 before you used +1999 :)
    ---
    Benjamin
    Yeah, must have been tired yesterday i see that now, haha.
Sign In or Register to comment.