How to pause the appearance of text in 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
User avatar
Zalor
Newbie
Posts: 22
Joined: Wed Jan 18, 2017 3:02 pm
Contact:

How to pause the appearance of text in choices?

#1 Post by Zalor »

For each choice, I would like for there to be a brief pause before the next one appears. For example:
"Go straight" (pause for 0.2 seconds)
then below that display "Go right" (pause for another 0.2 seconds)
then below that display "Go left"

Belgerum's response in this thread technically solved part of my problem:(viewtopic.php?t=46124)

But in addition to pausing the display of the choices, I would like to maintain a typewriter effect. Such as the one I use to display ordinary text. So using the previous example, I would like it to type out "Go straight", then pause for 0.2 seconds. Then type out "Go right", then pause for 0.2 seconds. And finally type out "Go left". The idea is that I want to simulate the feel of using an old computer. Which is why I don't want the text to appear all at once.

For a more precise example of what I'm talking about, the 43 second mark of this video (I believe the link is already timestamped) shows exactly a style of how I would like to present my choices: https://youtu.be/JPRiusZrafo?t=43

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

Re: How to pause the appearance of text in choices?

#2 Post by Alex »

Zalor wrote: Tue Dec 07, 2021 8:25 am ... I would like it to type out "Go straight", then pause for 0.2 seconds. Then type out "Go right", then pause for 0.2 seconds. And finally type out "Go left". ...
Try to modify choice screen like this

Code: Select all

transform choice_tr(t):
    # shows choice button offscreen
    # to prevent player from clicking it
    # before text appears
    xoffset config.screen_width
    t
    xoffset 0
    
screen choice(items, delayed = True, choice_delay = 0.2, choice_cps = 30.0):
    style_prefix "choice"

    vbox:
        for indx, i in enumerate(items):
            if not delayed: # ordinary menu
                textbutton i.caption action i.action
                
            else: # delayed menu
                $ text_delay = 0.0
                $ text_speed = 0.0
                if indx != 0:
                    for j in range(indx):
                        if choice_cps > 0:
                            $ text_delay += (len(items[j].caption) / choice_cps)
                    $ text_delay = text_delay + choice_delay * indx
                    if text_delay > 0:
                        $ text_speed = 1.0 / text_delay
                    
                # since wait-tag is not working, let's add one really-slow-space
                textbutton "{cps=[text_speed]} {/cps}" + i.caption action i.action text_slow_cps choice_cps at choice_tr(text_delay)
And use it like

Code: Select all

# The game starts here.
label start:
    "..."

    menu:
        "(delayed menu)"
        "Choice 1 - do something":
            pass
        "Choice 2 - do something else":
            pass
        "Choice 3 - do nothing at all":
            pass
            
    "another one"
    
    menu (delayed=False): # you can pass parameters (delayed, choice_delay, choice_cps) to change menu behavior
        "(normal menu)"
        "Choice 1 - do something":
            pass
        "Choice 2 - do something else":
            pass
        "Choice 3 - do nothing at all":
            pass
            
    "?!"

User avatar
Zalor
Newbie
Posts: 22
Joined: Wed Jan 18, 2017 3:02 pm
Contact:

Re: How to pause the appearance of text in choices?

#3 Post by Zalor »

Thank you very much for the thorough reply! I gave the code posted above a bit of a try, but honestly I think I'm in a bit over my head with this one. I got an error when I was compiling, although that's most likely an error on my part in trying to implement it. Eventually once I get other stuff on this project finished I might return to try another attempt at getting this to work. But for now I just want to emphasize my appreciation for going so far as to type out that code.

Post Reply

Who is online

Users browsing this forum: Google [Bot]