Code:
def realWait = { time ->
def msWait = (time * 1000);
def startTime = java.util.Calendar.getInstance().getTimeInMillis();
wait(time);
def endTime = java.util.Calendar.getInstance().getTimeInMillis();
def msWaited = (endTime - startTime);
def floorWaited = msWaited - (msWaited % 100);
if (msWaited < msWait) //Cheating of task occurred - Administer punishment? / Make it last the real time?
{
if ( (msWait / 4) == floorWaited) { /* Speed = Faster */ }
else if ( (msWait / 2) == floorWaited) { /* Speed = Fast */ }
else { /* Speed = Could of possibly flickered in between speeds during wait time */ }
/* Set a variable? Administer punishment? */
/* Use the below to wait the remainder of time really required */
//def finalWait = roundUpNumberByUsingMultipleValue(((roundUpNumberByUsingMultipleValue((msWait - msWaited), 100) * (msWait / msWaited))), 1000) / 1000;
def finalWait = Math.round(((msWait - msWaited) * (msWait / msWaited)) / 1000);
wait(finalWait);
}
/* Use the following to debug if you wish */
endTime = java.util.Calendar.getInstance().getTimeInMillis();
soFar = "#msWait("+msWait+") - Real time:" + ((endTime - startTime)/1000) + "\n" + soFar;
//show(soFar); /* Comment / un-comment as needed */
/* End of debug */
}
/* Use the following to debug / test accuracy */
for(def k = 1;k < 30;k++)
{
realWait(k);
}
def msWait = (time * 1000);
def startTime = java.util.Calendar.getInstance().getTimeInMillis();
wait(time);
def endTime = java.util.Calendar.getInstance().getTimeInMillis();
def msWaited = (endTime - startTime);
def floorWaited = msWaited - (msWaited % 100);
if (msWaited < msWait) //Cheating of task occurred - Administer punishment? / Make it last the real time?
{
if ( (msWait / 4) == floorWaited) { /* Speed = Faster */ }
else if ( (msWait / 2) == floorWaited) { /* Speed = Fast */ }
else { /* Speed = Could of possibly flickered in between speeds during wait time */ }
/* Set a variable? Administer punishment? */
/* Use the below to wait the remainder of time really required */
//def finalWait = roundUpNumberByUsingMultipleValue(((roundUpNumberByUsingMultipleValue((msWait - msWaited), 100) * (msWait / msWaited))), 1000) / 1000;
def finalWait = Math.round(((msWait - msWaited) * (msWait / msWaited)) / 1000);
wait(finalWait);
}
/* Use the following to debug if you wish */
endTime = java.util.Calendar.getInstance().getTimeInMillis();
soFar = "#msWait("+msWait+") - Real time:" + ((endTime - startTime)/1000) + "\n" + soFar;
//show(soFar); /* Comment / un-comment as needed */
/* End of debug */
}
/* Use the following to debug / test accuracy */
for(def k = 1;k < 30;k++)
{
realWait(k);
}