Text bleeps callback won't stop in menus [SOLVED!]

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
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Text bleeps callback won't stop when going to other menu

#16 Post by trooper6 » Tue Jun 02, 2015 12:59 pm

I wish you the best of luck with your project! And I'm glad the beeps are working for you!
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
tomotomo
Regular
Posts: 32
Joined: Thu May 28, 2015 2:01 pm
Tumblr: tomatomagica
Location: Russia
Contact:

Re: Text bleeps callback won't stop when going to other menu

#17 Post by tomotomo » Tue Jun 02, 2015 1:00 pm

trooper6, thanks a lot for your help again!

dino999z
Newbie
Posts: 11
Joined: Wed May 15, 2019 12:18 pm
Contact:

Re: Text bleeps callback won't stop in menus [SOLVED!]

#18 Post by dino999z » Sat Jun 29, 2019 3:27 pm

Hi there, how do you make the slider for adjusting the typing sound?

Mikasa01
Newbie
Posts: 13
Joined: Sat Jul 11, 2020 1:01 pm
Contact:

Re: Text bleeps callback won't stop when going to other menu

#19 Post by Mikasa01 » Fri Jul 31, 2020 11:42 am

trooper6 wrote:
Tue Jun 02, 2015 10:02 am
You don't need the no_game screen in your code since you never call it. That screen was for the option where you can't go to the menu while the slow text is running...but you aren't using that option, you are using the function option--so you don't need the screen.

To answer your question about having a bunch of different beeping sounds, you can achieve this by having a keyword variable in your callback to distinguish the different characters, pass that variable to the function and have an if statement in there that decides what beep to play based on the variable:

Code: Select all

init -1 python:
    #Register Audio Channel
    renpy.music.register_channel("Chan1", mixer= "sfx", loop=True)

    #Play Audio Function            
    def clack_play(on=False, char=1):
        if on:
            if char==1:
                renpy.music.play("click.wav", channel="Chan1")
            if char==2:
                renpy.music.play("pong_beep.wav", channel="Chan1")
        else:
            renpy.music.stop(channel="Chan1")

    #Callback
    def clicks(event, char=1, **kwargs):
        if event == "show" or event == "begin":
            clack_play(True, char)    
        if event == "slow_done" or event == "end":
            clack_play(False, char)
            
# names
define cha = Character(u"Шарлотта", show_two_window=True, what_slow_cps=20, stop_on_mute=False, callback=clicks, cb_char=1)
define dan = Character(u"Даниэлла", show_two_window=True, what_slow_cps=20, stop_on_mute=False, callback=clicks, ch_char=2)
I have to say, though...all those clicks for the entire game might annoy your player. Perhaps you should add an option to turn all those clicks off?
This is a bit of a necro so I apologize, but your code doesn't seem to be working. It always uses

Code: Select all

char=1
no matter what.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Text bleeps callback won't stop in menus [SOLVED!]

#20 Post by trooper6 » Sat Aug 01, 2020 2:23 am

I noticed a typo in that code that could have caused that problem. When I was defining dan, the last bit says: ch_char=2, but that should be cb_char=2
The "cb" stands for callback.

Anyhow, I just remade the project and tested it, it work. I'll post the code and also a zip of the project itself that you can download and test our yourself.

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"
image skimpy = Placeholder('boy')
image flippy = Placeholder('girl')


# Declare characters used by this game.
define e = Character('Eileen', image="skimpy", color="#c8ffc8", what_slow_cps=20, what_slow_abortable=False,
    stop_on_mute=False, callback=clicks, cb_char=1)
define f = Character('Faye', image="flippy", color="#c8ffc8", what_slow_cps=20, what_slow_abortable=False,
    stop_on_mute=False, callback=clicks, cb_char=2)

#Functions
init -1 python:
    renpy.music.register_channel("Chan1", mixer= "sfx", loop=True)

    def clack_play(on=False, char=1):
        if on:
            if char==1:
                renpy.music.play("audio/click.wav", channel="Chan1")
            if char==2:
                renpy.music.play("audio/pong_beep.wav", channel="Chan1")
        else:
            renpy.music.stop(channel="Chan1")


    def clicks(event, char=1, **kwargs):
        if event == "show" or event == "begin":
            #This is the function option
            clack_play(True, char)

        if event == "slow_done" or event == "end":
            clack_play(False, char)


# The game starts here.
label start:

    e "Let us test the callbacks."

    e "This character is using one set of beeps."

    f "But I'm differnt character, and I'm using different beep."

    return

BleepCallback.zip
(640.33 KiB) Downloaded 2 times
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Tayruu
Regular
Posts: 129
Joined: Sat Jul 05, 2014 7:57 pm

Re: Text bleeps callback won't stop in menus [SOLVED!]

#21 Post by Tayruu » Sat Aug 01, 2020 11:52 pm

The above download doesn't appear to actually stop the beeps in the menu. (Also the second sound effect is... pretty unpleasant.)

For my own project, I have to specifically mute the text channel when calling a screen from the main screen.

Code: Select all

label enter_game_menu:
    $ renpy.music.stop(channel="text")
    return
In the above code, the channel would be "Chan1".

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Text bleeps callback won't stop in menus [SOLVED!]

#22 Post by trooper6 » Sun Aug 02, 2020 12:21 pm

The second sound is very unpleasant. I’d never use it in an actual game. That is just for testing purposes. Also, that code doesn’t implement the menu fix because Mikasa didn’t quote my post dealing with muting the bleeps, just the post having different bleeps. The solution I posted earlier (adding a few lines to the menu screens) still works.

You can review that post here (it is the second half of the post): viewtopic.php?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Mikasa01
Newbie
Posts: 13
Joined: Sat Jul 11, 2020 1:01 pm
Contact:

Re: Text bleeps callback won't stop in menus [SOLVED!]

#23 Post by Mikasa01 » Sun Aug 02, 2020 3:57 pm

Thanks for providing a fix for the code. :)

Post Reply

Who is online

Users browsing this forum: No registered users