Code: Select all
screen countdown(timer_range, timer_jump):
zorder 9
default end_time = time.time() + timer_range
default current_time = time.time()
timer 0.05 repeat True action If(
current_time < end_time,
true=SetScreenVariable('current_time', time.time()),
false=[Hide('countdown'), Jump(timer_jump)]
)
# We have default dissolve in and dissolve out transform
bar value (end_time-current_time)*100 range timer_range*100 xalign 0.5 yalign 0.1 xmaximum 300 at notify_appear
viewtopic.php?p=440383#p440383
I just have to show and hide the screen whenever it's relevant, and so far it works well.
But I'd also like to be able to extend or cut the timer while it's counting down, for the purpose of giving the player character a time extension or penalty depending on the course of action they take.
I figure that I just need to externally modify the end_time screen variable, but I couldn't find how to do it from a label.
The thread itself is over 7 years old, so perhaps there's an easier and better solution today?