One thing I noticed is that even though there is an if statement at the end saying if there is less than 10 seconds left tack on a 0 in front of the digit, it still didn’t. I adapted the script to fit for countdowns under 60 seconds =]
//Full Function Countdown Script
//Written by Jason Vore - codered10@hotmail.com
//Edited by Nathaniel Schweinberg - nathaniel@ftcmedia.com
//Attach as an expression for the source text for a Text Layer.
intMinutesToCountdown = 0; //How many minutes you want to be counted down.
intSecondsToCountdown = 30; //How many additional seconds you want to be counted down.
offset = 2; //Number of seconds to hold the countdown timer at full before it starts counting down
boolIncludeMinutes = 0; //1 to include minutes, 0 to exclude
boolIncludeDecimalSeconds = 0; //1 to include decimal parts of seconds, 0 to exclue
intDecimalsToInclude = 0; //Number of decimal points to include
boolAllowNegativeTimes = 0; //1 to allow the countdown to run past 0, 0 to hold the timer at 0 seconds.
boolIncludeLeadingZeroes = 1; //1 to include leading zeroes in front of minutes to keep text in same location
//DO NOT EDIT ANYTHING BELOW THIS LINE!
i = inPoint + offset; //the "time" to actually start the countdown
intSecondsToCountdown = intMinutesToCountdown * 60+ intSecondsToCountdown; //calculates total seconds in the countdown
fltSecondsRemaining = intSecondsToCountdown - time + i; //decimal of number of seconds remaining, uses i start the countdown at the inpoint of the clip
if (fltSecondsRemaining > intSecondsToCountdown)
{
fltSecondsRemaining = intSecondsToCountdown; //If we haven't gotten out of the offset period, reset the timer to full.
}
if(!boolAllowNegativeTimes)
{
if(fltSecondsRemaining<0) fltSecondsRemaining = 0; //If we've passed zero seconds and user has chosen not to allow negative times, reset time to 0.
}
intMinutesRemaining = Math.floor(fltSecondsRemaining/60); //Calculates number of minutes remaining
decSecondsRemaining = fltSecondsRemaining - 60 * intMinutesRemaining; //reduces seconds to less than 60
intDecimalMultiple = Math.pow(10,intDecimalsToInclude); //Multiplier for placing decimal place in the correct spot.
decSecondsRemaining = Math.floor(decSecondsRemaining * intDecimalMultiple); // moves decimal to the right and chops remainder
dspSecondsRemaining = decSecondsRemaining/intDecimalMultiple; //prepare the seconds for display - puts the decimal point back where it belongs
if (!(decSecondsRemaining%intDecimalMultiple) && boolIncludeDecimalSeconds)
{
dspSecondsRemaining = dspSecondsRemaining + "."; //If we are at an even second and the user wants the decimal places displayed, tag the decimal point on to the string.
}
if(boolIncludeDecimalSeconds)
{
for (a=1;a<=intDecimalsToInclude;a++)
{
if(!(decSecondsRemaining%Math.pow(10,a)))
{
dspSecondsRemaining = dspSecondsRemaining+"0"; //Add appropriate trailing zeroes if we are showing decimals.
}
}
}
if(decSecondsRemaining < 10) //EDIT-Removed the boolean statement requiring boolIncludeMinutes
{
dspSecondsRemaining = '0' + dspSecondsRemaining; //if we are under 10 seconds and displaying minutes, and a leading 0 to the seconds
}
if(boolIncludeMinutes && intMinutesToCountdown >= 10 && intMinutesRemaining<10 && boolIncludeLeadingZeroes)
{
dspMinutesRemaining = '0' + intMinutesRemaining;
}
else
{
dspMinutesRemaining = intMinutesRemaining;
}
':' + dspSecondsRemaining