Use "real" instead of "integer". Real will allow decimals, Integer will not. As for the negative you may have to use a Rule to make it so it does not go negative.
On Rule "if Attribute < 0.00" Set To 0.00
Someone please correct me if I'm wrong or there's an easier way.
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
edited March 2013
Okay. Here are the attributes you have to work with:
Boolean (can't do numbers unless you count 0 and 1) Text (can display numbers but can't do math with them) Real (decimals!) Integer (no decimals) Index (no decimals; Mac only) Angle (no decimals)
So knowing that your only choice is Real, you would need to change or constrain the value to a positive number:
Socks, serious question, no trolling. As a half-way new programmer, when would that ever be useable? Can you give me an instance of when turning a negative number into it's positive counterpart would be the right thing?
Socks, serious question, no trolling. As a half-way new programmer, when would that ever be useable? Can you give me an instance of when turning a negative number into it's positive counterpart would be the right thing?
I got one! When your car is reversing, in the real world, I wouldn't want my speedo to go into negative figures, as the needle would end up pointing at my feet!
So therefore in a game using @Socks technique we can replicate this reality, so that even if your reversing, it shows the speed as a positive number. Otherwise, it would display as a negative number!
Useful!
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
Clearly I've been answering too many questions today. :P Thanks, @Socks.
Socks, serious question, no trolling. As a half-way new programmer, when would that ever be useable? Can you give me an instance of when turning a negative number into it's positive counterpart would be the right thing?
I got one! When your car is reversing, in the real world, I wouldn't want my speedo to go into negative figures, as the needle would end up pointing at my feet!
So therefore in a game using @Socks technique we can replicate this reality, so that even if your reversing, it shows the speed as a positive number. Otherwise, it would display as a negative number!
Useful!
If your car is stuck in reverse at 22mph, you'd want it to go to ZERO, not 22mph forward.
Socks, serious question, no trolling. As a half-way new programmer, when would that ever be useable? Can you give me an instance of when turning a negative number into it's positive counterpart would be the right thing?
If your car is stuck in reverse at 22mph, you'd want it to go to ZERO, not 22mph forward.
But as an indictor of how fast the vehicle is moving it is still useful - going forward or backward its speed is still 22mph - an abs-speedometer™ would let you know how fast you were going regardless of direction.
@Socks Bravo. I just couldn't imagine a reason for it which made me wonder... That's a perfect reason to use it. Thanks! Always glad to learn something new from people who are better than myself.
Comments
On Rule
"if Attribute < 0.00" Set To 0.00
Someone please correct me if I'm wrong or there's an easier way.
Boolean (can't do numbers unless you count 0 and 1)
Text (can display numbers but can't do math with them)
Real (decimals!)
Integer (no decimals)
Index (no decimals; Mac only)
Angle (no decimals)
So knowing that your only choice is Real, you would need to change or constrain the value to a positive number:
(see @Socks' answer below)
From the GS cookbook:
abs
Usage: abs(x)
The absolute value of the number. i.e. make the number positive if it is negative.
Examples:
abs(-42) = 42
abs(42) = 42
So therefore in a game using @Socks technique we can replicate this reality, so that even if your reversing, it shows the speed as a positive number. Otherwise, it would display as a negative number!
Useful!
Like this: