High score wont display. Bug?

Hi everyone,
I need help! I've tried everything and can't get this to work.

I have a score that is displayed with custom font that I used this tutorial to make:

When the player dies, I have a rule that says:

If Score (attribute) > Highscore (attribute),
constrain Highscore to score.

Then i have a rule to spawn the actors for Score and Highscore. The score works fine and displays fine. The problem is that the Highscore will only display the last number and won't display the rest of the numbers. Each number actor has this rule:

Constrain Self image to floor((game.Highscore%self.div)/(self.div/10))..".png" (For the second number the 10 is 100, etc.)

If i turn this rule off the actor will display, but as soon as i turn it on it doesnt display. I'm using windows version.

Is this a bug? its driving me nuts.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Can you send me a link to download the file (please .zip it first and upload it to a file-sharing site such as Dropbox or MediaFire)?

    These kinds of problems are usually easy to figure out if I have all of the rules in front of me.

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If you put Log Debugging Statements in your high score digit actors and change the expression to self.Image, you'll notice that if you have a high score of 678, you'll see this in the Debugger Window:

    Log(Actor: HS10): 8HS.png
    Log(Actor: HS100): 78HS.png
    Log(Actor: HS1000): 678HS.png

    In other words, your digits are taking the whole substring of the score up to that digit rather than just the digit they need (the hundreds digit should be 6HS.png, not 678HS.png).

    As an example, here's the expression in your HS1000 actor:

    floor(( game.HighScore % self.Div )/( self.Div /1000)).."HS.png"

    If you take a number like 12345678 and mod it by 1000 (%1000), you get 678. So far, so good. You then need to divide it by 100 to get 6.78, and then floor that to get 6, the hundreds digit. But your expression is dividing 678 by 1 (self.Div/1000) and getting 678.

    So you need to change that expression to this:

    floor(( game.HighScore % self.Div )/( self.Div /10)).."HS.png"

    I'm not going to write out all of the expressions for you but I hope that gives you some idea of how to proceed. By the way, I use Spotlight on a Mac (in Windows/Online any calculator with a mod (%) function will do) to figure this out because you can type in "floor((12345678%1000)/(1000/1000))" and it will return the value 678. Similarly, if you type in "floor((12345678%1000)/(1000/10))" it will return the value 6.

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

  • toastyteetoastytee Member Posts: 53
    Of course! Can't believe i didnt notice that. Thank you so much!!!
Sign In or Register to comment.