Milestone triggers

Hi, I'm not good at the math so I'm asking the question here. I have a game that has a score. The score grows and grows every time you play. It just continues on. i.e does not reset. The aim to my game is to ultimately reach 1,000,000points. I'd like to trigger an event every time the score clocks up another 1,000.

Now the this needs to happen at the end of the game (not when it hits 1,000 exactly) and the score might just be 4,234, but because the score passed 4,000 it needs to trigger. The next game might end on a score of 4,945, So no trigger. The next game we'll reach 5,345. So we need a trigger after the game ends.

Does anybody know of how I could calculate this?

The trigger I need is to simply bring on another actor to the screen to congratulate the player. So I'm guessing the rule could 'live' inside this actor.

Best Answers

Answers

  • ElfizmElfizm Member Posts: 489


    It fails when the score is exactly a multiple of 1000, though.
    @tatiang Not to sure what you mean by that but what if you just add 0.1 to it so it's 1000.1

    Just throwing out ideas.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2013
    I went with floor instead. Here's a demo. It works for everything but the initial score increase. lol... I'm lazy today. Make sure you have the volume on as I used a sound to indicate surpassing the previous thousand mark. You'll have to search the forums for large number formatting because you'll see that when you pass 1 million, you run into scientific notation. I believe the solution lies with the PadInt math function.

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

  • DoguzDoguz Member Posts: 500
    That's great @tatiang. Thanks for taking the time. I tried the ceil version and have is working as far as I can see. And your floor demo definitely works well too.

    Whats the difference between the two commands?
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2013
    Prec [precision] rounds as you would expect but uses decimal places.
    I've noticed that 'Prec' will return inaccurate results when using multiple decimal places.

    For example:
    prec(5.51,9) should return 5.510000000 but in fact returns 5.510000229, I don't suppose it really matters in the real world as the discrepancies are so small, I just thought it was odd for a mathematical calculation on a computer to be off by even a tiny amount ?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yeah, that is strange. I've never checked those functions carefully but it's good to be aware of that. Computers get confused easily.

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

  • joshiwujoshiwu Member Posts: 207
    edited July 2013
  • joshiwujoshiwu Member Posts: 207
    Also don't forget that you can use "else" Infinitely . for instance
    if score <=1000 do (something)
    Else if score <=2000 do (Something)
    Else If score <=3000 do (something)

    This effect is created by dragging a rule into the else section of a rule. And if you copy it into itself can grow exponentially (in design time). ty and yw
  • joshiwujoshiwu Member Posts: 207
Sign In or Register to comment.