Tracking Time

jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
edited November -1 in Working with GS (Mac)
I know I saw a post about this a few weeks ago, but I can't find it anymore. I'm looking to track how much time has progressed in levels. Right now I'm just tracking time in seconds, but how can I convert that into hrs minutes and seconds? I know I'll need 3 attributes, one for hours, one for minutes, one for seconds, but what's the math required?

I think for Hours I need the number of times 3600 goes in whole, for minutes how many times 60 goes in, and the remainder is seconds, but I'm lost on how to do that. anyone tackle this already?

Comments

  • EastboundEastbound Member, BASIC Posts: 1,074
    Use the modulous symbol %. So to find hours it would be:

    hours = seconds % 3600

    Or minutes:

    minutes = seconds % 60

    And the remaining seconds:

    seconds = seconds - (hours * 3600) - (minutes * 60)
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    awesome. thanks
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    this doesn't seem to work for minutes, I've got 360 as a default value, so when I do 360 % 60, it shows up as zero. Looking at what FireMapleGames said in this thread:

    http://gamesalad.com/forums/topic.php?id=1885#post-10322

    this is because 60 goes evenly into 360 with nothing left over. I need this to return 6 instead of 0. This works fine for seconds, as it would be an even minute. But for minutes, it doesn't cut it.

    secondly, since I'm using this for time, is there a way to get gamesalad to force double digits for values under 10?... 03 instead of just 3.
  • quantumsheepquantumsheep Member Posts: 8,188
    The title of this thread made me think...

    Mulcahy - fancy making a game called 'T is for Time Travel?' ;)

    QS :)
  • gregr209gregr209 Member Posts: 441
    YES! Mulcahy do it! 'T is for Time Travel' would be a great name for a game! Battle out different people or things from time!

    Greg
Sign In or Register to comment.