You might be finding that st is not resetting as there is no interaction between hide and show.
Does it work with a dialogue line between them?
If it does, you might get away with $ renpy.restart_interaction() or some redraw call
If you did want a versatile screen based one, maybe:
Code: Select all
style text_timer_ok:
size 72
color "#FFF"
outlines [(2, "#000", 0, 0)]
style text_timer_near:
size 72
color "#F22"
outlines [(2, "#000", 0, 0)]
init python:
def text_countdown( st, at,
duration = 10.0,
fail_label = 'fail_label',
screen = 'text_timer',
ok_style = 'text_timer_ok',
near_style = 'text_timer_near',
style_swap = 5.0,
text_format = "{minutes:02d}:{seconds:02d}:{micro_seconds[0]}" ):
remaining = duration - st
parts_dict = {
'minutes' : int( remaining // 60 ),
'seconds' : int( remaining % 60 ),
'micro_seconds' : str(int( (remaining % 1) * 10000 ))
}
if remaining <= 0.0:
renpy.hide_screen(screen)
renpy.call(fail_label)
return Text( text_format.format(**parts_dict),
style = ok_style if remaining > style_swap else near_style), .1
screen text_timer( **kwargs ):
# @param: kwargs
#
# duration = 10.0,
# success_label = 'success_label',
# fail_label = 'fail_label',
# screen = 'text_timer',
# ok_style = 'text_timer_ok',
# near_style = 'text_timer_near',
# style_swap = 5.0,
# text_format = "{minutes:02d}:{seconds:02d}:{micro_seconds[0]}"
vbox:
add DynamicDisplayable(text_countdown, **kwargs)
textbutton "Found Me":
action [ Function(renpy.hide_screen, 'text_timer'), Call(kwargs.get('success_label', 'success_label')) ]
label start:
"start"
call screen text_timer
"middle"
call screen text_timer(duration=22.0, text_format = "{minutes:02d}:{seconds:02d}" )
"end"
label success_label:
"Success"
return
label fail_label:
"Too slow"
return