Issue regarding timed Choices

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
PixelFade
Regular
Posts: 67
Joined: Mon Mar 25, 2013 11:20 pm
Contact:

Issue regarding timed Choices

#1 Post by PixelFade » Sat Jul 13, 2013 1:41 pm

Hello,

I'm having trouble figuring out this issue. The on-screen time is not matching the actual time.

Code: Select all

init:
    python:
        def countdown(st, at, length=0.0):

            remaining = length - st

            if remaining > 1.7:
                return Text("%.1f" % remaining, color="#fff", size=60), .1
            elif remaining > 0.0:
                return Text("%.1f" % remaining, color="#f00", size=60), .1
            else:
                return anim.Blink(Text("0", color="#f00", size=60)), None

So this has the proper on-screen time and the proper actual time.

Code: Select all

    $ countdownbase = 3
    $ countdowntotal = countdownbase + countdownplayer
    
    
    image countdown = DynamicDisplayable(countdown, length=countdowntotal)
    show countdown at Position(xalign=.24, yalign=.5)
    $ ui.timer(countdowntotal, ui.jumps("Fail"))
    menu:
        "Test":
            "Test"
Now if I do it again, the on-screen time is incorrect and hasn't changed, but the actual time is correct.

Code: Select all

    $ countdownbase = 0
    $ countdowntotal = countdownbase + countdownplayer
    
    
    image countdown = DynamicDisplayable(countdown, length=countdowntotal)
    show countdown at Position(xalign=.24, yalign=.5)
    $ ui.timer(countdowntotal, ui.jumps("Fail"))
    menu:
        "Test 2":
            "Test 2"
I've tweaked around as much as I am capable and am unsuccessful in resolving the issue. Anyone have some ideas?

Thank you for your time and help!

Best Regards.

PixelFade
Regular
Posts: 67
Joined: Mon Mar 25, 2013 11:20 pm
Contact:

Re: Issue regarding timed Choices

#2 Post by PixelFade » Tue Jul 16, 2013 11:14 am

Hello,

Anyone have any ideas? This is quite an integral component to our game and any suggestions or guidance at all would be helpful!

Best Regards.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Issue regarding timed Choices

#3 Post by Alex » Tue Jul 16, 2013 4:31 pm

Try screens instead

Code: Select all

screen timer_scr(place="Fail"):

    timer 1.0  action If(t_var>1, SetScreenVariable("t_var", t_var-1), [Hide("timer_scr"), Jump(place)] ) repeat True
    text "[t_var]" xalign 0.1 yalign 0.1

# The game starts here.
label start:
    "..."
    $ t_var = 5
    show screen timer_scr
    menu:
        "Choice":
            $ renpy.hide_screen ("timer_scr")
            pass
    "Win"
    
    $ t_var = 3
    show screen timer_scr(place="far_away_label")
    menu:
        "Choice":
            $ renpy.hide_screen ("timer_scr")
            pass
    "Win 2"
    return

label Fail:
    "Fail"
    jump start
    
label far_away_label:
    "far away..."
    return
http://www.renpy.org/doc/html/screen_py ... -functions
http://www.renpy.org/doc/html/screens.html#timer
http://www.renpy.org/doc/html/screen_actions.html

PixelFade
Regular
Posts: 67
Joined: Mon Mar 25, 2013 11:20 pm
Contact:

Re: Issue regarding timed Choices

#4 Post by PixelFade » Thu Jul 18, 2013 10:23 am

Alex wrote:Try screens instead

Code: Select all

screen timer_scr(place="Fail"):

    timer 1.0  action If(t_var>1, SetScreenVariable("t_var", t_var-1), [Hide("timer_scr"), Jump(place)] ) repeat True
    text "[t_var]" xalign 0.1 yalign 0.1

# The game starts here.
label start:
    "..."
    $ t_var = 5
    show screen timer_scr
    menu:
        "Choice":
            $ renpy.hide_screen ("timer_scr")
            pass
    "Win"
    
    $ t_var = 3
    show screen timer_scr(place="far_away_label")
    menu:
        "Choice":
            $ renpy.hide_screen ("timer_scr")
            pass
    "Win 2"
    return

label Fail:
    "Fail"
    jump start
    
label far_away_label:
    "far away..."
    return
http://www.renpy.org/doc/html/screen_py ... -functions
http://www.renpy.org/doc/html/screens.html#timer
http://www.renpy.org/doc/html/screen_actions.html
This worked! Thank you so much.

Post Reply

Who is online

Users browsing this forum: Google [Bot]