Timer not displaying down to hundreth decimal

MattButlerStudiosMattButlerStudios Member Posts: 486
edited June 2014 in Working with GS (Mac)

I am making a game that uses a timer. It is very important that the time be displayed all the way down to 0.01. However, when it gets to 0.10 the next number it goes to is 0. Why is this? Can someone please help me with the custom font math if that is the issue? Thanks!

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @MattButlerStudios Can you give more info to your programming for your timer? Cheers.

    P.S also check that any attributes pertinent to your timer are Real...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I'm sure the issue is with the custom font expressions. I know they can be lengthy but can you post a screenshot or type them here or post a link to download your project file (as a .zip)? It sounds like the problem is related to the last two digits (tenths and hundredths).

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

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    @gyroscope
    Hi thanks for the response. My attribute for the timer is real. I was counting down using a timer that said every .01 seconds change attribute game.timer to game.timer -.01. I don't know what is up but I think it may have to do with the code I am using for my custom font. Do you know what I should be putting in each 0 of my custom font?



    From Left to Right:

    1st zero code: floor( game.time %10)..".png"

    2nd zero code: (floor( game.time *10)%10)..".png"

    3rd zero code: floor(floor( game.time *100)%10)..".png"

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2014

    I assume you're using game.timer and not game.time. The formula for the 3rd zero (the hundredths digit) would result in 9.png when game.timer is 0.09. Have you verified this with a DisplayText behavior or Log Debugging Statement?

    The great thing about Spotlight on a Mac is that you can actually enter (floor(0.09*100)%10) and it will return 9.

    Oh and you don't need the ..".png" although I tend to include it.

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

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2014

    @MattButlerStudios said:
    gyroscope
    Hi thanks for the response. My attribute for the timer is real. I was counting down using a timer that said every .01 seconds change attribute game.timer to game.timer -.01. I don't know what is up but I think it may have to do with the code I am using for my custom font. Do you know what I should be putting in each 0 of my custom font?



    From Left to Right:

    1st zero code: floor( game.time %10)..".png"

    2nd zero code: (floor( game.time *10)%10)..".png"

    3rd zero code: floor(floor( game.time *100)%10)..".png"

    Hi again, Matt

    OK, make sure your Timer attribute is a real one (as I'm sure it is), set it to 30 (secs) or whatever you want, and try the following fine-tuning to what you've got already:

    Rule: When TimerGo is true
    -- nested in above -- Rule: When game.Timer > 0
    Timer Every 0.01 seconds Run to Completion
    Change Attribute game.Timer to game.Timer-0.01
    Otherwise
     Change Attribute TimerGo is false
    
    floor(( game.Timer %60)/10).."png"
    
    floor( game.Timer %10).."png"
    
    (floor( game.Timer *10)%10).."png"
    
     floor(floor( game.Timer *100)%10).."png"
    

    Hope that sorts it for you. :smile:

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • MattButlerStudiosMattButlerStudios Member Posts: 486
    edited June 2014

    Thanks for all of the excellent input @tatiang and @gyroscope‌! I have changed my timer to every 0.01 seconds change game.time to game.time-0.01. The code that you @gyroscope‌ gave me to try is the exact same that I already had, but with an extra digit correct? Right now I have 0.00 but you are saying to change it to 00.00? Also, I am using a self made attribute for the time that is in fact a real attribute. The code that you suggested (@gyroscope) started with the top being the first digit and so on correct? As a final question, how would you find out this math? It is really cool that spotlight can tell me the outcome, but can it produce that formula? I know I am asking a lot but I really appreciate your guys help! Thanks -Matt

    Also here is a video! http://s1175.photobucket.com/user/mattattack10/media/timerproblem_zps5c2c4980.mp4.html (I don't really know how to put a vid/picture on the forum from photobucket)

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited June 2014

    @MattButlerStudios said:
    The code that you gyroscope‌ gave me to try is the exact same that I already had, but with an extra digit correct?

    Hi Matt, yes.

    Right now I have 0.00 but you are saying to change it to 00.00?

    Um, only if you need to! i.e if your timer is to show more than 9 (whole) seconds... (I just assumed it was, despite you not showing that!)

    Also, I am using a self made attribute for the time that is in fact a real attribute. The code that you suggested (@gyroscope) started with the top being the first digit and so on correct?

    Good, and true!

    As a final question, how would you find out this math? It is really cool that spotlight can tell me the outcome, but can it produce that formula? I know I am asking a lot but I really appreciate your guys help! Thanks -Matt

    Not quite understanding this question - but enough to say, those formulas for a timer in GameSalad have been around almost as long as GameSalad has been around...

    There's a lot of vids + info available if you Google timer game salad or digital timer game salad - including a vid. from @tshirtbooth (just seen someone has called themselves @tshirtbooth2 - you've got an awful lot to live up to... :wink: -) )

    Also here is a video!

    http://s1175.photobucket.com/user/mattattack10/media/timerproblem_zps5c2c4980.mp4.html (I don't really know how to put a vid/picture on the forum from photo bucket)

    It's odd that Photobucket stuff isn't being shown properly now - it used to ... don't know if anyone else can shed some more light there...


    Finally to say, after your questions here, I'm not totally sure whether or not your problem is now solved...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • UtopianGamesUtopianGames Member Posts: 5,692

    We have a timer with 2 decimal places for Free over at DBA if it helps.

    Darren.

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    Wow @gyroscope‌ thank you for all of the time you spent answering my questions. You have been a great help! @deepblueapps thanks I will check it out!

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    @DeepBlueApps‌ I followed your tutorial and I am getting this result http://s1175.photobucket.com/user/mattattack10/media/video2_zpsb4dea84c.mp4.html In the video I slowed it down so that you can see when it gets to .10 right after it goes to 0. I still cannot find the problem!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    It's possible that you're experiencing a known bug: http://forums.gamesalad.com/discussion/62543/bug-when-subtracting-0-1-from-a-real-attribute.

    To check for the existence of this bug, try doing an every 0.1 second Timer with a Log Debugging Statement with game.timer (I avoid naming custom attributes the exact same thing as built-in attributes but that's up to you; there's already a built-in game.time attribute) or whatever you're calling your time left attribute.

    Also, a video of the results of rules is not nearly as useful as screenshots of the rules themselves.

    If you'd like, you can .zip your file and send me a private message with a link to download it. You might send it over to @gyroscope‌ as well since he's helpful and knowledgeable. Sometimes seeing the actual project file allows for a quick "aha!" moment where we recognize the problem.

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

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    Ok @tatiang‌, I'll send you and @gyroscope‌ a PM. Also, how would I use a game.time attribute (the one that is built in) to count down? I only see that it counts up?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Right, you can't use game.Time. I'm not saying there's anything technically wrong with creating a custom attribute called game.time... that's the correct process for counting down. I'm just mentioning that I wouldn't personally call it something so close to the built-in name... I'd call it game.countdownTime or something like that. ;)

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

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    @tatiang‌ Ok, I see what you're saying.

Sign In or Register to comment.