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 » Sun May 24, 2020 8:20 pm

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.

User avatar
rayminator
Veteran
Posts: 444
Joined: Fri Feb 09, 2018 12:05 am
Projects: Redoing games to fix spelling mistakes other companys that don't care
Location: Canada
Contact:

Re: Individual GUI button sounds

#2 Post by rayminator » Sun May 24, 2020 9:54 pm

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")]
when I try to help someone I point them into 2 direction what's right and wrong so they can learn how to

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

Re: Individual GUI button sounds

#3 Post by drdog » Sun May 24, 2020 11:30 pm

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: 3000
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Individual GUI button sounds

#4 Post by Imperf3kt » Sun May 24, 2020 11:49 pm

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.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

User avatar
Remix
Eileen-Class Veteran
Posts: 1455
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 » Mon May 25, 2020 11:17 am

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 » Mon May 25, 2020 3:45 pm

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: dGameBoy101b, Google [Bot]