Max integer?
SLOCM3Z
Member Posts: 797
Hello,
I was wondering how I could set a max number for an integer. I can do 'if attribute game.SoldierAmmo >= 156' :do: 'timer:"every 0.0001 change attribute game.SoldierAmmo :to: 156"'. But that seemed like to much. I was wondering if there is an easier way to stop the number. Like in FPS games, where you can only have a certain amount of ammo.
Thanks
Comments
Where ever you are adding to your ammo count create a rule with the condition "When game.SoldierAmmo <= to 156" and place your Change Attribute inside it.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
There are a couple of ways to do this:
When attribute game.SoldierAmmo ≥ 156 ... Constrain Attribute game.SoldierAmmo to 156.
Alter your Change Attribute so that it says something like When [condition] ... Change Attribute game.SoldierAmmo to min(game.SoldierAmmo+1,156).
I prefer #2. The min() function returns the smaller of two values, so it will never go above 156. You can add 1 or 10 or 100 or whatever you like... I just added 1 as an example.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks guys!