Force sound to play fully (for lightning with sound via ATL)

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
MoonByte
Regular
Posts: 173
Joined: Thu Mar 24, 2016 9:18 pm
Completed: Shine (RPG Maker), Heroes (RPG Maker), Lantern Bearer (RPG Maker), Loop the Loop (Unity), Other Stars (Unreal), Sky Eye (RPG Maker), WIN Delivery & Fateful (Ren'Py)
Projects: Weird Is Normal (Ren'Py)
Location: Germany
Contact:

Force sound to play fully (for lightning with sound via ATL)

#1 Post by MoonByte »

I have a "lightning with sound" code which looks like this:

Code: Select all

init -1 python:
    def thunder_sound(trans, st, at):
        renpy.play("audio/sound/thunder.mp3", channel="sound")

image lightning:
    choice: #weight of choice is 1
        "lightning.png"
        alpha 0.0
        function thunder_sound
        0.5 # show nothing for 0.5 seconds


    choice 0.1: #weight of choice is 0.1
        "lightning.png"
        alpha 0.0
        function thunder_sound
        linear 0.3 alpha 1.0
        linear 0.3 alpha 0.0

    choice 0.1:
        "rev_lightning"
        alpha 0.0
        function thunder_sound
        linear 0.3 alpha 1.0
        linear 0.3 alpha 0.0
It works just fine, like it flashes, no errors and I technically hear a sound...
And I say technically, cause the sound plays for maybe half a second and then just stops. I assume something in that code forces the sound to stop the second that the animation is done? Which obviously I don't want, I want the thunder sound to play fully. And just to clarify: it's NOT that the sound stops because the next lightning happens. It just cuts off instantly, even when the next flash is 12 seconds away.

The only mention of "force play" for sound that I could find was this Reddit thread which suggests to queue sounds. But using the above function with queue gives me errors.
Anyone got any idea on what to do?

Post Reply

Who is online

Users browsing this forum: No registered users