Here is the code for the timer that I found on another forum post. The only thing I changed is the length of the timer.
Code: Select all
init:
python:
# This function will run a countdown of the given length. It will
# be white until 5 seconds are left, and then red until 0 seconds are
# left, and then will blink 0.0 when time is up.
def countdown(st, at, length=0.0):
remaining = length - st
if remaining > 2.0:
return Text("%.1f" % remaining, color="#fff", size=72), .1
elif remaining > 0.0:
return Text("%.1f" % remaining, color="#f00", size=72), .1
else:
return anim.Blink(Text("0.0", color="#f00", size=72)), None
# Show a countdown for 60 seconds.
image countdown = DynamicDisplayable(countdown, length=60.0)
Code: Select all
show countdown
$ ui.timer(5.0, ui.jumps("timesup"))
Code: Select all
label timesup:
hide countdown
stop music
mc "I'm completely lost..."