Creating an "accurate" lap timer and milliseconds.

This forum is currently in read-only mode.
From the Asset Store
Tabata timer
$9.99 USD
Template for Tabata timer, fully documented in comments and video
  • Hey folks, back again with something I am stumped on. I am trying to create a visible and accurate lap timer and almost instantly ran into an issue of displaying milliseconds at an accurate rate. I noticed that when you use the "every milliseconds" condition that there is a notice that says "milliseconds wait between triggers". I have tried to build a timer from scratch and don't seem to understand how to accurately get the milliseconds to display in real time.

    I searched the construct wiki for a solution and noticed there was an "object" called "profiler" and the wiki described it as dealing with high resolution timers but there was no info on how to use this object or it's purpose in detail.

    I put together a very quick cap file that shows what I am trying to achieve and I know it is absolutely inaccurate and might even be the hard way of going about building the timer but you can at the least see what I am trying to achieve.

  • You can use the System expression "timer.  "timer" gives the number of milliseconds that have passed since the game started.

    Save the start time in a variable and then you can find the number of milliseconds elapsed with:

    timer - start_time

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • My concern is how to correctly "display" the milliseconds during the lap process and not so much catching the time when crossing the finish line.

    Also retrieving the milliseconds from the system timer it returns in decimal form with multiple digits. I really want to understand how to correctly put the timer together but man I am confused.

  • Here is an example: ... e.cap?dl=1


    Event 8 in particular:

    int('total'/60000) & ":" & zeropad(int('total'/1000)%60 ,2) & "." & zeropad('total'%1000, 3)

    I changed timer from decimal to an integer with int(timer).

  • int('total'/60000) & ":" & zeropad(int('total'/1000)%60 ,2) & "." & zeropad('total'%1000, 3)

    Line 8 was exactly what I was looking to achieve and I truly smiled when I saw how you simplified that down. I made just a few minor adjustments to add an extra zero to the minutes and changed the decimal in front of the milliseconds to a colon.

    zeropad(int('totaltime'/60000),2) & ":" & zeropad(int('totaltime'/1000)%60 ,2) & ":" & zeropad('totaltime'%1000, 3)

    I was truly going about it the wrong way. Thanks ROJOhound for the detailed example! It helped me to also understand how to use "int" and bracket correctly when using math.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)