Typewriter SFX 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
Amie
Regular
Posts: 28
Joined: Tue Jun 06, 2017 4:48 am
Contact:

Typewriter SFX problem.

#1 Post by Amie »

Hi guys, I'm using the code below to give my in-game dialogue the 'typewriter' sound effect.

Code: Select all

init python:
    def callback(event, **kwargs):
        if event == "show":
            renpy.music.play("SFX/Text.ogg", channel="typewriter", loop="True")
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="typewriter")
This works great, but the problem is that if you open the main menu (by pressing the right mouse button) mid sentence, the text sound just loops forever unless you exit the menu screen, is there any way to make the typewriter sound automatically stop if the menu is opened?

Thanks in advance for any help. :)

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

Re: Typewriter SFX problem.

#2 Post by philat »

Code: Select all

screen save():
    # This ensures that any other menu screen is replaced.
    tag menu
    on "show" action PauseAudio("typewriter", "toggle")
    on "hide" action PauseAudio("typewriter", "toggle")

User avatar
Amie
Regular
Posts: 28
Joined: Tue Jun 06, 2017 4:48 am
Contact:

Re: Typewriter SFX problem.

#3 Post by Amie »

Thanks Philat, I'll give this a try tomorrow :D

User avatar
Amie
Regular
Posts: 28
Joined: Tue Jun 06, 2017 4:48 am
Contact:

Re: Typewriter SFX problem.

#4 Post by Amie »

Thanks again for trying to help, Philat, but I've given that code a try and it doesn't have the effect I was hoping for. With your code, I press the right mouse button and no menu shows up at all... but what I was hoping to do was just stop the typewriter sound when a menu is opened, I'm sure there must be a way to do it, but I'm not too good with the coding side of things yet...

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

Re: Typewriter SFX problem.

#5 Post by Imperf3kt »

Where did you place it? In the save screen Ren'Py already comes with (removing the initial two lines) or elsewhere in your screens file?
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
Amie
Regular
Posts: 28
Joined: Tue Jun 06, 2017 4:48 am
Contact:

Re: Typewriter SFX problem.

#6 Post by Amie »

Ah, that was what I was getting wrong I guess :D

OK, so I've put it in the right place now, replacing the old two lines, and it kinda works but there's some unexpected side effects, for example, sometimes you click to enter the menu, but then after a second it will automatically exit the menu for no apparent reason...

Post Reply

Who is online

Users browsing this forum: Google [Bot]