Convert milliseconds to...

Get help using Construct 2

Post » Thu Jul 26, 2012 12:37 am

Did you check out ramones' example? To me it sounds like it does everything you want except store the total time elapsed in milliseconds, is that correct?

If it is correct, just make another variable "t" like you have in your case, and instead of the "Set text to timer*1000" action in ramones' example, do "Set t to timer*1000". Now the "t" variable will hold the total amount of time elapsed in milliseconds, and the text will show the time in "min:sec:mill" with 2, 2 and 3 numbers respectively.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jul 26, 2012 12:43 am

Probably not the most elegant, but I've fixed with by adding a second event.

1) right("00"&(int(milliseconds / 60000) % 60),2) & ":" & right("00"&(int(milliseconds / 1000) % 60),2) & ":" & (milliseconds % 1000)

2) left(CurrentTime.text,9)

This allows the code to be shown correctly, but I'm sure there's an easier way from within point 1).

Any ideas?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Thu Jul 26, 2012 11:46 am

What you really want is to display centiseconds and not milliseconds?
minutesSecondsCentiseconds.capx (r95)
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Thu Jul 26, 2012 1:07 pm

Fascinating... this method does it with only the use of 1 variable and 1 additional line. I can then have another variable that I can use to store the data. I really like that there's so many ways to do one thing. I like having options.

Do you happen to know a way to have it display 00:00:000 (note the 3 at the end). This would enable me to have it as more precise.

Thanks for your help!

EDIT: Ahh, done it!

zeropad(floor(timer/60),2) & ":" & zeropad(floor(timer)%60,2) & ":" & zeropad(floor(timer*1000)%1000,3)AnD4D2012-07-26 13:12:11
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Mon Sep 03, 2012 11:25 am

"I have a timer set up which displays minutes:seconds:milliseconds. Each kind is its own variable. It's displaying it as a text box, and so I can not use it to compare best times, etc."

AnD4D, have you managed to do this, are you able to save the best times, i am trying to do the same, but no result. Please send me capx. or a screenshot with the events, for more then 2 months i can`t finish my game because of this...
B
10
S
3
G
3
Posts: 54
Reputation: 3,317

Post » Tue Sep 04, 2012 1:11 pm

@legora

Yep, thanks to these guys I managed it. In the end I had the time count everything in miliseconds, and then convert this to M:S:MS.

If I remember, I'l post a cap when I get back from work. Feel free to poke me...
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Mon Apr 22, 2013 8:10 pm

[QUOTE=ramones] What you really want is to display centiseconds and not milliseconds?
minutesSecondsCentiseconds.capx (r95)[/QUOTE]

This is great code - thanks @ramones.
B
32
S
7
G
8
Posts: 312
Reputation: 8,467

Post » Sat Mar 15, 2014 10:00 pm

@ramones - thanks for putting up that snippet - saved me 20 minutes of frustration coming up with my hack version and I learned something at the same time
B
31
S
8
G
5
Posts: 436
Reputation: 5,836

Previous

Return to How do I....?

Who is online

Users browsing this forum: h1k3, Unconnected, Yahoo [Bot] and 0 guests