[SOLVED] Countdown Timer won't jump to a label when it ends?

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
CaleAlexander
Newbie
Posts: 6
Joined: Sun Dec 30, 2018 11:32 pm
Projects: i got you
Deviantart: calealexander
itch: calealexander
Contact:

[SOLVED] Countdown Timer won't jump to a label when it ends?

#1 Post by CaleAlexander »

I'm having some trouble with my countdown timer. When the timer ends I want it to immediately jump to a label but right now it just flashes 0 and does nothing. There's no error message, it just doesn't do anything.
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)
Here's the code I have several lines down for starting the timer and jumping to the label "timesup" when it ends (also pasted from the other post.)

Code: Select all

    
    show countdown
    $ ui.timer(5.0, ui.jumps("timesup"))
Here's the label "timesup" several lines down.

Code: Select all

label timesup:
    hide countdown
    stop music
    mc "I'm completely lost..."
Any way to get this to work? I'm very new to renpy so apologies if the solution is obvious.
Last edited by CaleAlexander on Mon Jan 14, 2019 12:03 am, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Countdown Timer won't jump to a label when it ends?

#2 Post by philat »

That's pretty old code. Try something newer, like viewtopic.php?f=8&t=33120#p379109

CaleAlexander
Newbie
Posts: 6
Joined: Sun Dec 30, 2018 11:32 pm
Projects: i got you
Deviantart: calealexander
itch: calealexander
Contact:

Re: Countdown Timer won't jump to a label when it ends?

#3 Post by CaleAlexander »

Thanks, but I'm not attempting to use a single timed menu for this portion. The player has to navigate through several different menus within a time limit. Here's a section of my code for this:

Code: Select all

label gspuzzlep2:
    menu:
        "Left aisle":
            play sound "kart.wav"
            jump incorrect2
        "Center aisle":
            play sound "kart.wav"
            jump correct5
        "Right aisle":
            play sound "kart.wav"
            jump incorrect3

Code: Select all

label correct5:
    menu:
        "Left aisle":
            play sound "kart.wav"
            jump incorrect2
        "Center aisle":
            play sound "kart.wav"
            jump incorrect3
        "Right aisle":
            play sound "kart.wav"
My intention is a minigame like the Lost Woods in Zelda where you have multiple paths and if you go the wrong way you go back to the beginning. Is there any way to make this work with a time limit or should I scrap the timer all together? Thanks.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Countdown Timer won't jump to a label when it ends?

#4 Post by philat »

Uh... that has nothing to do with the screen I linked to. Just show the countdown screen and put whatever puzzle you want after it, it'll still jump after the timer unless you turn it off.

CaleAlexander
Newbie
Posts: 6
Joined: Sun Dec 30, 2018 11:32 pm
Projects: i got you
Deviantart: calealexander
itch: calealexander
Contact:

Re: Countdown Timer won't jump to a label when it ends?

#5 Post by CaleAlexander »

Sorry for my confusion, I was getting errors trying to paste this into my script file so I assumed the menus were the issue. It actually works perfect, thanks so much for your patience! :^)

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: [SOLVED] Countdown Timer won't jump to a label when it ends?

#6 Post by isobellesophia »

Hi! If you ever want to edit your countdown timer, you can visit this site:

https://www.renpy.org/wiki/renpy/doc/co ... imed_menus




Hope i could help :shock:
I am a friendly user, please respect and have a good day.


Image

Image


CaleAlexander
Newbie
Posts: 6
Joined: Sun Dec 30, 2018 11:32 pm
Projects: i got you
Deviantart: calealexander
itch: calealexander
Contact:

Re: [SOLVED] Countdown Timer won't jump to a label when it ends?

#7 Post by CaleAlexander »

Thanks, that should be helpful later :D

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], crowcinthus, Google [Bot], Yahoo [Bot]