trying to display countdown based on timer, but stop at 0

LeanneLeanne Member Posts: 168
edited September 2012 in Working with GS (Mac)
display text 10-self.time, but would like it to stop at 0 instead of going into negative numbers. I have tried a number of different ways to know avail. Wondering if anyone has a quick answer.

Comments

  • MantoManto Member Posts: 796
    Rule:
    if 10-self.time ≥ 0
    display text 10-selftime
    otherwise
    display text 0
  • LeanneLeanne Member Posts: 168
    i know it's probably obvious, but how can I do "if 10-self.time?" Can't seem to find a way to put "10-" into the first part of the rule or pull up the expression editor...

    I did try to make an attribute, change game.attribute to 10-self.time
    then, if game.attribute is greater than or equal to 0, display text 10-self.time, otherwise display 0, buy it still goes down past 0.

    this should be simple, right?
  • LeanneLeanne Member Posts: 168
    i also used padInt(3-self.Time,2) so it would not display the decimals. Is this somehow impeding the other rule from working?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2012
    Two ways:

    (1)
    Rule: When self.Time [less than or equal to] 10
    ...DisplayText 10-self.time
    Otherwise
    ...DisplayText 0

    (2)
    Constrain attribute self.TimeLeft (index) to 10-self.Time
    DisplayText self.TimeLeft

    Note: index attributes are limited to >= 0 values so it won't go negative, but you'll only see the integer values counting down.

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

  • LeanneLeanne Member Posts: 168
    used the first. worked like a charm. thank you muchly.
Sign In or Register to comment.