Forum Discussion

MattRichards134's avatar
MattRichards134
Community Member
6 months ago

Converting total seconds into minutes and seconds format.

Hi,

I've been developing a maze type game which currently has variables set up for Minutes and Seconds as well as a variable that tracks the number of "wall hits" when the users mouse collides with a wall. With the help of some triggers I have the total time showing in Minutes and Seconds format. However, I'm trying to include a penalty type system based on the wall hits.

For example, each wall hit is a 2 second penalty. I want to then display the final total time on the final layer.

I think JavaScript of some sort may be needed but basically I'm trying to do the following:

  • Multiply the WallHits variable by 2 to get the PenaltySeconds
  • Convert the Minutes into seconds and add this to both the Seconds and PenaltySeconds variables to get the total time taken in seconds format. For example, if the user took 1 minute 30 seconds with 5 wall hits - this would then end up as 100 seconds (60 secs + 30 secs + (5x2 = 10) seconds.
  • I then need to somehow convert that final seconds number back into a minutes and seconds format that can then display to the user

I know this is potentially a lot of information but wondering if the above would be achievable in any way? 

Many thanks,

Matt

No RepliesBe the first to reply