My objective is to test a timer to check and see if the idea will work before I implement it into my RPG Maker project. Originally, there's a building block method in the software to make the timer/clock, but I'm trying to move on from that and create a JavaScript code to do just that. Thing is, I need it to pause for a brief moment, so the timer doesn't break. It'll be a day/night cycle in the game.
The test timer will be used to check and see if the idea works, and if not to debug. So far it works, but I am unable to pause it.
var min = 0;
var hour = 0;
var timer = true;
alert("Testing Timer");
do{
sec += 10; //Needs to pause for 5 secs after this line
console.log(sec);
if(sec >= 60){
alert("It's " + hour + " : " + min + " : " + sec);
min += 5;
sec = 0;
if(min >= 60)
{
hour += 1;
min = 0;
}
}
}while(timer === true);```
you can use the
setTimeout
function to add a delay of 5 secs(5000 millisecs)