Dialogue callback sound problem

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
tim640
Regular
Posts: 48
Joined: Wed May 23, 2018 4:47 pm
Contact:

Dialogue callback sound problem

#1 Post by tim640 »

Yeeeeeah well. Finishing touches to the interface of the game are the hardest, polishing is hard, huh :oops:
Another problem that i ran into. So i have a callback defined right in the beginning on the "script.rpy" which makes a sound play while text is appearing in the dialogue window. It looks like that:

Code: Select all

init python:
    def callback(event, **kwargs):
        if event == "show":
            renpy.music.play("music/text.mp3", channel="sound")
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="sound")
        return
Then i add the callback to every character that appears on the screen:

Code: Select all

define e = Character("Meteorite", callback=callback)
BUT. If the text is still displaying (still hasn't finished appearing, and the sound is still playing), and a game menu button is being pressed, triggering the game menu to appear, the sound just goes on. If i press "Y" to hide the dialogue window, the sound also still plays until i show the window again and the text finishes appearing. Even if i chose "Exit to Main Menu" which is the "MainMenu" action, the sound CONTINUES. Until a file is loaded or a "label Start" is triggered.

I tried to solve this like that:

Code: Select all

init python:
    def callback(event, **kwargs):
        if event == "show":
            renpy.music.play("music/text.mp3", channel="sound")
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="sound")
        if event == "ShowMenu()":
            renpy.music.stop(channel="sound")
        return
But it didn't work. What i am doing wrong?.. Or maybe there's another way to add the sound to the dialogues so it'd work differently and stop when the menu is being opened?

As always, thank you for attention <3

User avatar
tim640
Regular
Posts: 48
Joined: Wed May 23, 2018 4:47 pm
Contact:

Re: Dialogue callback sound problem

#2 Post by tim640 »

UPD.: partly solved by adding

Code: Select all

$renpy.music.stop(channel="sound")
in the beginning of "game_menu" code part, now the sound stops if i open the menu in the middle of the dialogue appearance! However, the problem with "hide_windows" is still the same, if i hide the interface during the message, the sound still goes on. Any ideas? :<

Tried to add smthng like

Code: Select all

init python:
    def callback(event, **kwargs):
        if event == "show":
            renpy.music.play("music/text.mp3", channel="sound")
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="sound")
        if event == renpy.hide("say"):
            renpy.music.stop(channel="sound")
        return


but i guess i should state it somehow different. But how? I also thought of just adding an event of pressing a button there which i think should work - something like

Code: Select all

if event == button_pressed("hide_windows"):
            renpy.music.stop(channel="sound")
i am just not sure how to state it correctly. Please help ;_;

Post Reply

Who is online

Users browsing this forum: Bing [Bot]