Dialogue that loops for a certain amount of time

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
Red_Bobcat
Newbie
Posts: 5
Joined: Tue Apr 06, 2021 8:57 am
Contact:

Dialogue that loops for a certain amount of time

#1 Post by Red_Bobcat »

Hello. This is my first post so please forgive any mistakes I've made.

I've finished the tutorial and searched online, but can only find out of date information on how exactly to implement timed choices and interactions.

I have a screen that shows an unskippable animation, and I have a character speak over the top of it.

Code: Select all

$ renpy.choice_for_skipping()
    show screen unskippable_thing
    with Dissolve(.5)

    e "I am talking{w=1.8}{nw}"

    e "While you watch{w=2.5}{nw}"

    e "The unskippable{w=2.5}{nw}"

    e "Thing{w=2.5}{nw}"
    
     e "Click all you want{w=2.5}{nw}"
     
     e "It's not over{w=2.5}{nw}"

    e "Till it's over."
HOWEVER, if the player clicks the screen, the dialogue skips forward without displaying for the full amount of time, meaning that the animation runs in the background until it's complete without any dialogue on screen.

What I would like, is for a timer so that if the player clicks on the last line of dialogue before the animation has completed, the player is jumped back to the beginning of the dialogue again to click through once more, or into a seperate loop of new dialogues. Whichever is easier.

I'd also like to do it without having a custom timer constantly running in the background. This is a one time thing in the game, and I don't really want the game to possibly slow down because of it. I assume that with things like {w=2.5}, Dissolve(2.5) and pause 2.5 there must be an internal timer. Is there a way to only have an option available until after a certain amount of time has passed using that internal time alone?

Thank you very much for your help

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Dialogue that loops for a certain amount of time

#2 Post by Per K Grok »

Red_Bobcat wrote: Tue Apr 06, 2021 9:20 am Hello. This is my first post so please forgive any mistakes I've made.

I've finished the tutorial and searched online, but can only find out of date information on how exactly to implement timed choices and interactions.

I have a screen that shows an unskippable animation, and I have a character speak over the top of it.

Code: Select all

$ renpy.choice_for_skipping()
    show screen unskippable_thing
    with Dissolve(.5)

    e "I am talking{w=1.8}{nw}"

    e "While you watch{w=2.5}{nw}"

    e "The unskippable{w=2.5}{nw}"

    e "Thing{w=2.5}{nw}"
    
     e "Click all you want{w=2.5}{nw}"
     
     e "It's not over{w=2.5}{nw}"

    e "Till it's over."
HOWEVER, if the player clicks the screen, the dialogue skips forward without displaying for the full amount of time, meaning that the animation runs in the background until it's complete without any dialogue on screen.

What I would like, is for a timer so that if the player clicks on the last line of dialogue before the animation has completed, the player is jumped back to the beginning of the dialogue again to click through once more, or into a seperate loop of new dialogues. Whichever is easier.

I'd also like to do it without having a custom timer constantly running in the background. This is a one time thing in the game, and I don't really want the game to possibly slow down because of it. I assume that with things like {w=2.5}, Dissolve(2.5) and pause 2.5 there must be an internal timer. Is there a way to only have an option available until after a certain amount of time has passed using that internal time alone?

Thank you very much for your help


One thing you could to to match the dialogue with the time of the animation is to make the dialogue "non-clickable". You do that when defining the character by adding 'advance=False' to the definition. You will probably want the characters dialog clickable at other times. You fix that by having two characters, e and e2, identical except that e2 have advance=False. (advance=True is default)

Code: Select all

define e = Character("Eander")
define e2 = Character("Eander", advance=False)

label start:

    e2 "I am talking{w=1.8}{nw}"

    e2 "While you watch{w=2.5}{nw}"

    e2 "The unskippable{w=2.5}{nw}"

    e2 "Thing{w=2.5}{nw}"

    e2 "Click all you want{w=2.5}{nw}"

    e2 "It's not over{w=2.5}{nw}"

    e "Till it's over."



e2's dialog will advance only according to the time set.

e's line will advance on click.

To the player, e2 and e will be the same character.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2400
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Dialogue that loops for a certain amount of time

#3 Post by Ocelot »

Just a quck addition. If your character is heavily customised, you do not need to copy everything. You can create characters using existing character as base: Character("Eander", advance=False, kind=e)
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Dialogue that loops for a certain amount of time

#4 Post by Imperf3kt »

Another option is to use a hard pause before your lines of dialogue.
$ pause(5, hard=True)
The nw tags will still progress your dialogue, but the player will be unable to click to advance.

Note though that many players very strongly dislike control being taken away from them like this. There are uses where such a thing is necessary, but try not to overuse it.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Red_Bobcat
Newbie
Posts: 5
Joined: Tue Apr 06, 2021 8:57 am
Contact:

Re: Dialogue that loops for a certain amount of time

#5 Post by Red_Bobcat »

Thank you all very much for the help, I've ended up coming about it in a slightly different way.

I'm aware that players dislike control being taken away, so wanted to avoid removing their option to click to advance. Instead, I've created a loop of text with a random number generator so that each loop provides a random dialogue choice. This way, players can still advance dialogue (sort of), but not advance past the animation.

Code: Select all

    label convo_loop:
    $ convo_options = renpy.random.randint(1, 4)
    if convo_options == 1:
        e "text text text{w=2.5}{nw}"
    elif convo_options == 2:
        e "more text{w=2.5}{nw}"
    elif convo_options == 3:
        e "a third lot of text{w=2.5}{nw}"
    else:
        e "Etc, etc, etc{w=2.5}{nw}"

    jump convo_loop

    label convo_continue:
    
    e "Game continues from here"
    
Each dialogue choice ends with "{w=2.5}{nw}" so that even if the player doesn't click, it still scrolls through choices. However, at the end of the animation screen I've added...

Code: Select all

timer 20.0 action Jump("convo_continue")
Which means that while the animation is playing, the player can skip dialogue but it will loop them back until the animation has completed playing. Once the animation is done, it will automatically jump them past the loop to the rest of the game.

The code is a bit ugly, and it has some weird side effects if you scroll back (the text in the loop starts advancing and looping very quickly as if it's being skipped, even when skip isn't on), BUT I was planning on turning off the feature to scroll backwards during this section anyway...

I think this is done? Unless anyone can see any obviously problems with my solution?

Thanks again

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot], Semrush [Bot]