How to: Delay sound playing without renpy.pause?

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.
Message
Author
User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

How to: Delay sound playing without renpy.pause?

#1 Post by Winterslice » Mon Jan 25, 2016 11:11 am

I was wondering if there were some method by which I can incorporate a delay in playback without having to use a pause statement that would stop the say screen from continuing? Couldn't find anything about it in the documentation. Manually adjusting the length of the sound files is sadly not an option due to randomisation.

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#2 Post by Winterslice » Mon Jan 25, 2016 11:33 am

Alternatively, and possibly even handier, would be some method of keeping text on the say screen while paused rather than blanking it out.

User avatar
Iylae
Regular
Posts: 73
Joined: Sat Jan 09, 2016 6:57 am
Location: Cornwall, UK
Contact:

Re: How to: Delay sound playing without renpy.pause?

#3 Post by Iylae » Mon Jan 25, 2016 11:36 am

Have you tried using interact=false before the pause?
$ renpy.say(None, "blah blah blah", interact=False)
It works for keeping the text on the screen for a menu, so I'm going to take a leap of logic and say it'd work for pause too.
Image
  If we are what we repeatedly do, then good coding is not an act, but a habit

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#4 Post by Winterslice » Mon Jan 25, 2016 11:43 am

Interesting! I was totally unaware that that was a thing. Thanks for pointing me in that direction, I'll definitely investigate.

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#5 Post by Winterslice » Tue Jan 26, 2016 1:58 am

Okay, I've been experimenting, and interact=False can largely do what I want in a clumsy way... But the text still gets caught up in transitions, which looks bad. Is there any way to exclude things from a transition somehow?

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

Re: How to: Delay sound playing without renpy.pause?

#6 Post by philat » Tue Jan 26, 2016 2:53 am

I don't know what you're trying to do exactly, so it's difficult to know if this would be optimal for you, but one possible avenue would be use a timer in a screen. Something like

Code: Select all

screen delayedplay(time, file):
    timer time action Play("sound", file)
and then simply show the screen in the game with time and file specified.

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#7 Post by Winterslice » Tue Jan 26, 2016 3:08 am

philat, I thought of that, but I need it to be a more modular, able to handle timing for multiple items at once.

Basically, from a label I want to choreograph the sounds to coincide with delayed visual effects on a screen. I could hand-code clunky timers into every single cutscene screen, but as I said, a modular solution would save me ten tons of headache and repetition.

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

Re: How to: Delay sound playing without renpy.pause?

#8 Post by philat » Tue Jan 26, 2016 3:13 am

Given that you can pass times and files to the screen, why is this not a "modular" solution that would work for you? Yes, you need to know the times and files to pass, but presumably you know that anyway (whether randomly generated or otherwise). Again, I have no idea how you set up your system or exactly what you're trying to achieve so I'm shooting blind here.

ETA: Anyway, to answer your question from above my post, you can apply a transition to a particular layer, I suppose. I don't think there's an easy way to exclude just the text (as opposed to anything else on the screen layer -- which is where text shows up by default, being part of the say screen).

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#9 Post by Winterslice » Tue Jan 26, 2016 3:31 am

I'm not really using any kind of 'system.' Just screens that have delayed transforms, and playing sounds from a label by way of a for loop.

For 'passing times and files to the screen,' wouldn't showing the same screen multiple times just replace/cancel the previous instance of the screen? It's not very modular if I have to pass umpteen variables to it with six lines of timers going at once.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to: Delay sound playing without renpy.pause?

#10 Post by xela » Tue Jan 26, 2016 3:46 am

Winterslice wrote:For 'passing times and files to the screen,' wouldn't showing the same screen multiple times just replace/cancel the previous instance of the screen? It's not very modular if I have to pass umpteen variables to it with six lines of timers going at once.

Code: Select all

$ ui.timer(1.5, Play("sound", "sfx/sound.wav"))
?
Like what we're doing? Support us at:
Image

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#11 Post by Winterslice » Tue Jan 26, 2016 3:55 am

xela wrote:
Winterslice wrote:For 'passing times and files to the screen,' wouldn't showing the same screen multiple times just replace/cancel the previous instance of the screen? It's not very modular if I have to pass umpteen variables to it with six lines of timers going at once.

Code: Select all

$ ui.timer(1.5, Play("sound", "sfx/sound.wav"))
?
Man, I really wish those ui functions were better documented. That could've been handy elsewhere. But in this case, it only plays one sound and ignores all subsequent commands. (Sounds are not playing on the same channel, so that's not the problem.) Is there any way I can get it to do multiple things?

Can screen timers be placed inside if statements? That might solve my problem.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to: Delay sound playing without renpy.pause?

#12 Post by xela » Tue Jan 26, 2016 3:57 am

Yes, you can place both ui and screen timers in if/else forks. ui module is largely made obsolete with the screen language but some of it's functions are still valid and even used by the screens through wrappers (or at least were, SL2 changed loads of stuff).
Like what we're doing? Support us at:
Image

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#13 Post by Winterslice » Tue Jan 26, 2016 3:59 am

xela wrote:Yes, you can place both ui and screen timers in if/else forks. ui module is largely made obsolete with the screen language but some of it's functions are still valid and even used by the screens through wrappers (or at least were, SL2 changed loads of stuff).
Cheers. I'm going to try something. Will report back.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How to: Delay sound playing without renpy.pause?

#14 Post by xela » Tue Jan 26, 2016 4:01 am

Oki, you can also do this:

Code: Select all

init python:
    def func(...):
        ...

$ ui.timer(1.5, func, args=(), kwargs={})
It's hard to imagine it getting any more convenient than this.
Like what we're doing? Support us at:
Image

User avatar
Winterslice
Veteran
Posts: 228
Joined: Mon Sep 28, 2015 3:51 am
Completed: The Next World, Golem Creation Kit
Organization: Illuminated Games
Contact:

Re: How to: Delay sound playing without renpy.pause?

#15 Post by Winterslice » Tue Jan 26, 2016 7:04 am

I actually ended up doing it with screen timers on a loop, using a dict to feed it sounds and times, since ui.timer won't do more than one thing. Works great, and I can select either random sounds or go through them in sequence.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]