SOLVED! (Dialogue Speed/Sound Before Dialogue Ends/Dialogue Pause Before Auto-Continuing)

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
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

SOLVED! (Dialogue Speed/Sound Before Dialogue Ends/Dialogue Pause Before Auto-Continuing)

#1 Post by Offworlder »

I'm a complete coding newbie, so I apologize in advance if these questions have an unreasonably simple solution.

Here's what I'm trying to do:

1. Have lines of dialogue (or narration) play at different speeds, and/or have part of the dialogue/narration play at normal speed, pause, then play the rest of the dialogue.
For example:
"What's going on? (pause 0.5)
What's. (pause 1.5) Going. (pause 1.5) On?!?"
OR
"Hello, everyone! (pause)
...How was your summer?"

SOLVED! Thanks, Imperf3kt.


2. Similar to the above, have dialogue play at normal speed, pause, play a sound effect, then have dialogue finish at normal speed once the sound effect ends.

I hope all of this makes sense! I would truly appreciate if someone can help out.

SOLVED! Thanks, philat.
Last edited by Offworlder on Sat Sep 15, 2018 9:28 pm, edited 5 times in total.

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

Re: Questions Regarding Text

#2 Post by Imperf3kt »

You can use the wait tag for that
https://www.renpy.org/doc/html/text.html#text-tag-w

Code: Select all

    "What's going on?"
    $pause 0.5
    "What's. {w=1.5} Going. {w=1.5} On?!?"
If you don't supply a length of time (in seconds), Ren'Py waits until a player clicks.

Also, 1.5 seconds (twice) is a reeeeaaaaaly long time for the effect you're going for.
I suggest 0.3 or less.

The same link has other functions you can use to achieve your second request. Experiment with timing.
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

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions Regarding Text

#3 Post by Offworlder »

Imperf3kt

Thank you so much for your quick response!
I couldn't get "$pause" to work properly. But with a bit of tweaking, just using "{w=}" in its place works like a charm!

I'm unfortunately not seeing where the link you sent shows how to have a sound play before dialogue completes, followed by the rest of the dialogue after it completes (without clicking)...It's absolutely possible I just overlooked it, or merely don't understand.

On a separate note, I can't actually...seem to get sounds to play. I made a folder called "sfx" and placed a ".ogg" file in it, then used the code "play sound", followed by the name of the sound file in quotes. However, I keep getting an error stating that Ren'py can't find the sound file. "sfx" clearly shows in Atom under "images", "gui", etc. I'm not sure what I'm doing wrong...

EDIT: Oh! I also meant to say that my examples were purely made up for this thread. Especially after testing it out, I agree 100% that 1.5 seconds is excruciatingly long. xD

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

Re: Questions Regarding Text

#4 Post by Imperf3kt »

I wasn't sure if I had the correct pause syntax. Its been ages since I last used it.

As for the audio, in options.rpy, is config.has_sound set to True?

The link I sent doesn't cover playing sounds, but it does cover playing multiple lines of text.

Something like this should work if I understood the documentation right (I haven't tested this)

Code: Select all

    "3...{w=1.0}2...{w=1.0}1{w=1.0}{nw}"
    play sound "kaboom.ogg"
    "3...{w=1.0}2...{w=1.0}1{w=1.0}{fast} BANG!"
Also, with audio, I like to define it this way:

Code: Select all

define audio.sunshine = "music/sunshine_a.ogg"
define audio.gunshot = "sfx/gunshot.ogg"

label start:
    play music sunshine
    play audio gunshot
    #etc
    
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

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions Regarding Text

#5 Post by Offworlder »

Whoops! Didn't realize I had to define anything. x_x
With your suggestion, I ended up just changing the statement to " play sound "sfx/DinnerBell.ogg" " and it worked perfectly!

This bit isn't quite working for what I'm trying to do, though:

Code: Select all

    "3...{w=1.0}2...{w=1.0}1{w=1.0}{nw}"
    play sound "kaboom.ogg"
    "3...{w=1.0}2...{w=1.0}1{w=1.0}{fast} BANG!"
[/quote]

It actually ALMOST works. The first part of the text plays, then the sound plays, then BANG plays (with no clicks necessary throughout). However, BANG plays at the same time as the sound. I'm wanting the sound to play, then BANG right after. I tried playing around with the code a bit, but I still couldn't figure it out. I apologize for all of the trouble!

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

Re: Questions Regarding Text

#6 Post by Imperf3kt »

What if you add a wait right after the {fast} tag?

Code: Select all

    "3...{w=1.0}2...{w=1.0}1{w=1.0}{nw}"
    play sound "kaboom.ogg"
    "3...{w=1.0}2...{w=1.0}1{w=1.0}{fast} {w=0.5}BANG!"
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

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions Regarding Text

#7 Post by Offworlder »

YES! That's exactly what I was looking for!
I have just one final issue, now that you've figured out all the necessary starts and stops:

This is supposed to happen in the middle of a character's dialogue. However, once the sound starts playing, it removes the character's name/turns into narration.
If I add the character tag at the start of the line that contains "BANG", it leaves the name but requires a click to get there.

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

Re: Questions Regarding Text

#8 Post by Imperf3kt »

Thats not something I know about. It shouldn't work like that though.

Sorry, I can't help with that issue. You may wish to consult with someone more skilled than myself.


N.b.
You could remove the fast tag and it should still function identically except if text appears slower than instantly.
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

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions Regarding Text

#9 Post by Offworlder »

The "fast" tag seems to be extremely important in this case. Without it, "3...2...1" repeats when the sound plays, and "BANG" takes much longer to show up.

No worries about being unsure how to resolve the last issue. I'm extremely grateful for all of the help you were able to provide! Thanks to you, I'm one step away from everything working exactly as I envisioned. :3

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

Re: Questions Regarding Text

#10 Post by Imperf3kt »

There is one other way, but I am unfamiliar with it.
You can use the sound file with a delayed start and place it before the line of dialog, or another option is to enqueue a playlist with some silence at the start.

I'm not at my PC right now, or I'd give you an example.
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

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions Regarding Text

#11 Post by Offworlder »

Having a delayed start for the sound is a great suggestion!
Unfortunately, I don't think it'll work for what I'm trying to do. Unless I'm misunderstanding, I assume the idea would be to have X seconds of delay after the sound is inserted. If that's the case, the pacing will be off depending on how fast the player reads.

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

Re: Questions Regarding Text

#12 Post by philat »

Code: Select all

    e "3...{w=1.0}2...{w=1.0}1{w=1.0}{nw}"
    play sound "kaboom.ogg"
    extend "{w=0.5}BANG!"
Assuming e is your character.

User avatar
Offworlder
Regular
Posts: 114
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions Regarding Text

#13 Post by Offworlder »

You are absolutely brilliant, Philat! The code worked perfectly. ^.^
The two of you have answered all my questions. Undoubtedly, my project will be better because of it! Thank you so much for helping out.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Ocelot