So I am trying to make a time function that counts down. It's based on something I saw here. The variables are given from a different function. Once time runs out the variable finish is turned to 1 and it leaves the function. This function works sometimes and sometimes it doesn't work, for example if i give it an input of 11sec it works fine but if i give it 1:00 min it doesn't work. Can someone tell me what's wrong with the code.
if (time1 == 0 && time2 == 0 && time3 == 0 && time4 == 0)
//if all the time is 0 finish the sequence
finish = 1;
if (time1 != 0) //Checking to see if the first digit is NOT at 0
time1 = time1 - 1; // subtract time 1 by 1
else {
time2 = time2 - 1; //When time1 is 0
time1 = 9;
} //Time1 going back to it's original value
if (time2 == 0 && time1 == 0) { //if time1 and time2 are 0s
if (time3 != 0) { //The minute value (time3)
time2 = 5; //60 SECONDS
time3 = time3 - 1;
time1 = 9;
}
} //Put time 1 to its original value
if (time2 <= 0 && time1 <= 0 && time3 <= 0) {
if (time4 != 0) { //The minute value (time3)
time2 = 5; //60 SECONDS
time3 = 9;
time4 = time4 - 1;
time1 = 9;
}
} //Put time 1 to its original value
Time4 = 3, Time3 = 2, Time2 = 1, Time1 = 0. This will mean that the time is at 32:10 min