Reset current_time when restarting game?

A

AFD456

Guest
Hi guys,

I'd love to know If it's possible to reset current_time when I restart game? Time reset itself only when I end the game and then run it all over again. Thank you for your answers!

Code:

Create Event:

miliseconds = 0
seconds = 0;
minutes = 0;
hours = 0;

//timer start immediately
count_up = true;//.

Step Event:

if (count_up == true)
{
miliseconds = ((current_time ) mod 1000)
seconds = ((current_time ) div 1000) mod 60 //increment seconds by 1 ever real-time second.
minutes = ((current_time ) div 60000) mod 60
hours = ((current_time ) div 3600000) mod 3600
}

Keyboard Event for <Enter> Key:

///restart
game_restart()

// I thought this could work; It doesnt...
miliseconds = 0
seconds = 0
minutes = 0
 
A

Aura

Guest
No because it is a read only variable that will return the number of milliseconds that have passed since the OS was started. And that CAN'T change. You can however create a custom variable and increase it by delta_time every step. It will tell how many milliseconds have passed since the game was started and will get easily reset when you restart the game.
 
A

AFD456

Guest
No because it is a read only variable that will return the number of milliseconds that have passed since the OS was started. And that CAN'T change. You can however create a custom variable and increase it by delta_time every step. It will tell how many milliseconds have passed since the game was started and will get easily reset when you restart the game.
if (count_up == true)
{
myTime = myTime + delta_time/1000000
}

How to make it show minutes as well not only seconds and miliseconds. Otherwise it works fine!
 
A

Aura

Guest
Keep a seperate variable for that which is incremented by one each time the seconds variable is 60 and reset the latter back to 0.

Code:
if (seconds > 59)
{
   minutes += 1;
   seconds = 0;
}
 

Yal

šŸ§ *penguin noises*
GMC Elder
Or you could do like this to keep the variables in sync...
Code:
seconds = floor(myTime * 0.001)
TimeSeconds = seconds mod 60;
TimeMinutes = (seconds div 60) mod 60
TimeHours = seconds div 3600
 
Top