attributes

i need an attribute that doesn't go into negatives but does go into decimals.

Comments

  • DepressedPandaDepressedPanda Member Posts: 215
    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.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 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:

    (see @Socks' answer below)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Real + abs

    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
  • DepressedPandaDepressedPanda Member Posts: 215
    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?
  • iCreationZiCreationZ Member Posts: 158
    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!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Clearly I've been answering too many questions today. :P Thanks, @Socks.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • DepressedPandaDepressedPanda Member Posts: 215
    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. :)
  • SocksSocks London, UK.Member Posts: 12,822
    @DepressedPanda
    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?
    Things that bounce.
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    @DepressedPanda

    Like this:

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    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.
  • DepressedPandaDepressedPanda Member Posts: 215
    @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. :)
Sign In or Register to comment.