So, I am making a game and in this game, there are points. Points can be earned or spent. I know how to add points= (set: $points it +10) And I know how to subtract (set: $points to it -1) but the problem with subtracting is the fact that it can go into negatives (example: the no. of points is 0 but the player still starts the (set: $points to it -1) script so the no of points he has is -1) But, I want it to be so if the player enables a script where it subtracts from $points and he has a negative no. of points, then it will instead of doing (set: points to it -1) it will broadcast a message saying that “You have no points, nice try!” any idea how? Thanks, HouseonaTree
(if: $points > 0)[(set: $points to it - 1)]
This works okay if you only ever reduce by 1. However, if you later decide to reuse this code where it could be any number and wouldn’t know if it’d push you into the negatives, the following is a safer method.
(set: $points to it - $amount)
(if: $points < 0)[(set: $points to 0)]
1 Like
Thanks a lot. It worked!
Oops. I didn’t see that part.
(if: $points - 1 < 0)[You have no points, nice try!]
(else:)[(set: $points to it - 1)]
I think that should be what you want.
2 Likes
I forgot too ! Thank´s for reminding me and solving a great problem (for me anyway!), once again!
1 Like