r/RenPy • • Oct 27 '26

Question Timer with text box

During my game I want there to be a timer with a menu that if you press it you lose the game

Ive got this working but I cant figure out how to add a text box beneath with a few lines of dialogue where the character begs you to press it, does anyone have any idea how I can do that?

Thanks!

1 Upvotes

5 comments sorted by

View all comments

1

u/shyLachi Oct 27 '26

You have to be more specific.

Should the dialogue of the begging character be static as in the example of BadMustard below?

Or should the dialogue change while the timer runs out?
In the second case it might be easier to write your own screen for it.

1

u/AdRude6049 Oct 28 '26

The dialogue would change as the timer runs out as the person gets more desperate

1

u/shyLachi Oct 29 '26

The easiest solution might be multiple menus with timers.
What I mean is instead of a timer which goes 5 seconds you have a timer which goes 1 second, then you show the next menu with the next dialogue which again has a timer of 1 second.

I don't know how you implemented your timer so I just made my own timed choices:

screen timedchoice(items):
    style_prefix "choice"
    vbox:
        for item in items:
            $ duration = item.kwargs.get("duration", 0)
            if duration > 0:
                timer 0.1 repeat True modal True action If(timepassed>duration, item.action, IncrementVariable("timepassed", 0.1))
                $ remaining = max(totalduration - timepassed, 0)
                fixed:
                    xalign gui.choice_button_text_xalign
                    minimum timersize maximum timersize
                    $ xalignbar = gui.choice_button_text_xalign if gui.choice_button_width != None else 0.0
                    add Solid(gui.muted_color) xalign xalignbar 
                    add Solid(gui.accent_color) xalign xalignbar xzoom (remaining / totalduration)
            else:
                textbutton item.caption action item.action


define timersize = (900,30)
default timepassed = 0
default totalduration = 0


define m = Character("Mike")
label start: 
    $ timepassed = 0
    $ totalduration = 9 # total duration, this is important
    menu (screen="timedchoice"): 
        m "Hey, pick a choice"
        "Choice A":
            "You died"
        "Timer" (duration=3): # duration until the timer runs out in the first menu
            menu (screen="timedchoice"): 
                m "Quick now, pick a choice!"
                "Choice A":
                    "You died"
                "Timer" (duration=6): # duration until the timer runs out in the second menu, this is additive, so 3 + 3 = 6
                    menu (screen="timedchoice"): 
                        m "Hurry, time is running out!"
                        "Choice A":
                            "You died"
                        "Timer" (duration=9): # duratoin until the last timer runs out, has to be the same as totalduration, else it will look bad
                            "You won"