#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# How can make a count up timer that shows Hours, Minutes, Seconds & Milliseconds?

Posts: 388Member, PRO
edited July 2015

it would be in this format of two digits each 00:00:00:00 or maybe 00:00:00:0 with just one digit for the milliseconds

I'm making a simple puzzle game and I would like to time how long or fast it took to solve the puzzle.

• Posts: 388Member, PRO

@Socks said:

it sez Invalid Expression, lol

• London, UK.Posts: 12,821Member

@Dell7730 said:
it sez Invalid Expression, lol

Can you upload a screenshot of the expression.

• Posts: 388Member, PRO

@Socks said:
Can you upload a screenshot of the expression.

Just kidding, I got it, thanks again Sir!

• Posts: 388Member, PRO

@tintran said:
You can use the game.Time or self.Time(actor variable) to get number of seconds have passed, and then do your own math, to figure out hours,minutes,seconds,milliseconds
like
to get hundredths of seconds: padInt(floor(game.Time*100%100),2)

then you can join them all together using ..":"..

the .. just joins strings together. and the colon (:) is in quotes for the whole thing to work.

If you want to set your own start_time to save game.Time or self.Time then when the puzzle is solved you can set your own end_time to save game.Time or self.Time..
and subtract start_time from end_time should give you number of seconds that took to solve the puzzle and you can use this number of seconds in the above padInt calls instead of game.Time.
Hope that helps.

I took too long to replied and got ninja'd by both of you hehe

Socks is king

Socks is not just King but also the Queen, lol

• Posts: 453Member

@Dell7730 said:
Socks is not just King but also the Queen, lol

Are you saying that Socks is female gender?

• Posts: 388Member, PRO

@tintran said:

Next question is.... I want the time to be the final score to show who's the fastest. will the strings inside the Display Text be saved to submit in the leaderboards?

• Posts: 388Member, PRO

@tintran said:

hahahaha

• London, UK.Posts: 12,821Member

@Dell7730 said:
will the strings inside the Display Text be saved to submit in the leaderboards?

Saved to what or to where ?

• Posts: 388Member, PRO

@Socks said:

as the final score that can be posted to the leaderboards

• Posts: 25Member

How can i save this timer to show when finish my game