How to make a rule that when minus from something is equal to or greater than zero?

Hello

Was wondering if there is a special symbol used for this issue;

I have total points attribute,
I have total amount of points that can be earned attribute,
I have total number of moves made attribute.

Once the player finishes a level, The amount of points that is earned is determined by (number of points that can be earned) minus (number of turns).

However sometimes this becomes a negative and then messes up the whole point system. Is there a way I can say that if (number of moves) is equal to or greater than (number of points that can be earned) then change amount of points earned to 0.

Des this Make sense?

Best Answers

  • gyroscopegyroscope I am here.Posts: 6,598
    Accepted Answer

    Hi @MilliionairApps

    Something like:

    Change Attribute PointsEarned to PointsCan - TurnNum
    Rule: When PointsEarned < 0
    Change Attribute PointsEarned to 0
  • BoomshackBarryBoomshackBarry Posts: 712
    edited August 2013 Accepted Answer
    You could use an index attribute instead of an integer (if you're using an integer that is). An index operates the same as an integer except that it can't go below 0, so will effectively achieve what you want without the use of extra rules.

    From the cookbook:

    "Index: positive whole numbers, such as 0, 1, 58, 2804. Index attributes can fulfill many of the same roles as Integers, but have the interesting feature of being unable to store a negative number. For instance, an index attribute with a value of 4 that was told to subtract 6 would then have a value of 0, not -2."

Answers

  • MillionairAppsMillionairApps Member Posts: 110
    edited August 2013
    @gyroscope

    Cheers mate, that was my initial thought and it works, but then I tried @BoomshackBarry method and it works just the same, except it involves one rule not 2.
    Very helpful thanks, and I just re-learnt that index attributes can not go below 0.
  • BoomshackBarryBoomshackBarry Member Posts: 712
    No worries :) I think Index must be the least used attribute type, but in situations like this it comes in pretty handy!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited August 2013

    You're welcome, @MillionairApps – and @BoomshackBarry solution is better than mine, for certain, being less rules. :-) (I'd forgotten about index...)
  • BoomshackBarryBoomshackBarry Member Posts: 712
    Poor old index, nobody ever remember he's even there... :-S
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    @boomshackBarry more people should read that over at least once.
  • MillionairAppsMillionairApps Member Posts: 110
    @boomshackBarry more people should read that over at least once.
    I agree, but when you read the cookbook over two years ago, you tend to forget the same things that are never used in games created during that period.

  • BoomshackBarryBoomshackBarry Member Posts: 712
    Yeah it's easy to forget about techniques when you don't use them too often. If I had the time I'd like to work on regular mini projects alongside my main games specifically to get me used to things I don't work with often.
Sign In or Register to comment.