Page 2 of 2

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

Posted: Tue Jun 02, 2015 12:59 pm
by trooper6
I wish you the best of luck with your project! And I'm glad the beeps are working for you!

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

Posted: Tue Jun 02, 2015 1:00 pm
by tomotomo
trooper6, thanks a lot for your help again!

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

Posted: Sat Jun 29, 2019 3:27 pm
by dino999z
Hi there, how do you make the slider for adjusting the typing sound?

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

Posted: Fri Jul 31, 2020 11:42 am
by Mikasa01
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.

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

Posted: Sat Aug 01, 2020 2:23 am
by trooper6
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 25 times

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

Posted: Sat Aug 01, 2020 11:52 pm
by Tayruu
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".

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

Posted: Sun Aug 02, 2020 12:21 pm
by trooper6
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?

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

Posted: Sun Aug 02, 2020 3:57 pm
by Mikasa01
Thanks for providing a fix for the code. :)