Countdown using a variable amount.

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
Skiegh
Regular
Posts: 38
Joined: Mon Dec 19, 2011 2:47 pm
Contact:

Countdown using a variable amount.

#1 Post by Skiegh »

Title says it all, mostly. I was using just a normal count number alongside the screen I have going with a timer on it but if the person happens to go backwards for whatever reason, the timer variable may go back to where it was but the generic countdown amount does not. So I was wondering if I could use the variable itself and put it on screen in the top right?

For reference, this is what I'm using now...

Code: Select all

image countdownlong:
    DynamicDisplayable(countdown, length=30.0)
    xalign 1.0 yalign 0.0
default tim = 0
screen timer_swap():
    timer 1 repeat True action SetVariable("tim", tim + 1)

label whatevertheheck:
    show countdownlong
    show screen timer_swap
    "Blah blah dialogue/menu/whatever"

    ## If they go back to this spot or another, the countdown continues regardless, desyncing it from the "tim" variable. Thus the problem.
    "Fluff fluff fluff."

    "Fliff fliff fliff."

    if tim >= 30:
       hide timer_swap
       hide countdownlong
       jump thesolutiontothisproblem
    else:
       "Working as intended."
As always, thanks in advance.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Countdown using a variable amount.

#2 Post by Milkymalk »

The docs for DynamicDisplayable say "function is called at the start of every interaction". Could it be that every single say-statement resets the countdown?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Post Reply

Who is online

Users browsing this forum: No registered users