Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init python:
- import time
- # The wall time at which the timer should expire.
- timer_end_time = None
- # The place where we should jump to when the timer runs out.
- timer_target = None
- def timer_overlay():
- if timer_end_time is not None:
- ui.timer(timer_end_time - time.time(), ui.jumps(timer_target))
- config.overlay_functions.append(timer_overlay)
- def timer_start(duration, label):
- global timer_end_time
- global timer_jump
- timer_end_time = time.time() + duration
- timer_jump = label
- def timer_end():
- global timer_end_time
- timer_end_time = None
- # Use this like:
- label event:
- $ timer_start(10, "time_up")
- "Code here."
- $ timer_end()
- jump rest_of_game
- label time_up:
- "Time's up!"
- jump rest_of_game
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement