Individual GUI button sounds

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
drdog
Newbie
Posts: 4
Joined: Sun May 24, 2020 8:09 pm
Contact:

Individual GUI button sounds

#1 Post by drdog »

Hi,

I'm trying to make the "save" button in the text box play a certain sound when clicked. I've done some research but can't figure out how to customize GUI buttons individually.

Help as to how to go about this is greatly appreciated. Thanks.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Individual GUI button sounds

#2 Post by rayminator »

it should look like this Play("sound", "Sound/Saved Game.wav")

Code: Select all

textbutton _("Save") action [QuickSave("Save complete", newest=True), Play("sound", "Sound/Saved Game.wav")]

drdog
Newbie
Posts: 4
Joined: Sun May 24, 2020 8:09 pm
Contact:

Re: Individual GUI button sounds

#3 Post by drdog »

Hi, thanks for the quick reply. I put the code in the gui.rpy and got this error (and yes, I replaced the audio file):


File "game/gui.rpy", line 426: expected statement.
textbutton _("Save") action [QuickSave("Save complete", newest=True), Play("sound", "Sound/Saved Game.wav")]
^

Ren'Py Version: Ren'Py 7.3.5.606
Sun May 24 23:28:25 2020
[/code]


Did I put it in the wrong spot perhaps? Not sure what to change.

Thanks.

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

Re: Individual GUI button sounds

#4 Post by Imperf3kt »

The error says "expected statement", which indicates you've placed it in the wrong spot, yes.

That textbutton would be placed in the screen that uses it, not within gui.rpy--its a button (screen element) ready to use.
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
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Individual GUI button sounds

#5 Post by Remix »

You might also take note of the activate_sound and hover_sound parameters to buttons...

Code: Select all

    textbutton _("Save"):
        action QuickSave("Save complete", newest=True)
        activate_sound "audio/clickety_click.ogg"
        hover_sound "audio/dull_whisper.ogg"
Those two are actually style settings, so you could add them to the style that a group of buttons use rather than individually per button
Frameworks & Scriptlets:

drdog
Newbie
Posts: 4
Joined: Sun May 24, 2020 8:09 pm
Contact:

Re: Individual GUI button sounds

#6 Post by drdog »

Thanks, got it working. Didn't realize the code I had to replace was in screens.rpy. Much appreciated.

Post Reply

Who is online

Users browsing this forum: No registered users