Toggle Optional Player Voice Acting in preferences GUI?

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
Fluffyre
Newbie
Posts: 9
Joined: Wed Apr 01, 2020 7:38 am
Contact:

Toggle Optional Player Voice Acting in preferences GUI?

#1 Post by Fluffyre » Wed Apr 01, 2020 10:10 am

I want to have the ability for players to toggle optional voice acting for the player character in the preferences menu. One for male voice, and one for female.

I'm brand new to Ren'Py, and have no idea how to go about coding this in. Any help is appreciated, and I'll make sure to check in here frequently to answer any questions.

User avatar
qirien
Miko-Class Veteran
Posts: 538
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Discord: qirien
Contact:

Re: Toggle Optional Player Voice Acting in preferences GUI?

#2 Post by qirien » Wed Apr 01, 2020 3:12 pm

You can edit the Preferences menu in screens.rpy. Then you could add in some code like this:

Code: Select all

vbox:
                    style_prefix "radio"
                    label _("PC Voice")
                    textbutton _("Male") action SetVariable("voice_gender", "male")
                    textbutton _("Female") action SetVariable("voice_gender", "female")
Then, in your code, where you normally call:

Code: Select all

voice "male_line01.ogg"
You should instead call a function that can check the voice gender and play the right sound. For example:

Code: Select all

python:
    def v(filename):
        renpy.voice("voice_gender_" + filename + ".ogg")

label start:
    $ v("line01")
    mc "This should play using the right gender from the Preferences menu."
If you're going to use auto-voicing, then you could probably do it a different way with player tags, but to me this seems the easiest
See https://www.renpy.org/doc/html/voice.html
Finished games:
Image
Image
Image

Fluffyre
Newbie
Posts: 9
Joined: Wed Apr 01, 2020 7:38 am
Contact:

Re: Toggle Optional Player Voice Acting in preferences GUI?

#3 Post by Fluffyre » Thu Apr 02, 2020 2:49 pm

Thank you! I'll test this out once I get my voice lines in. ^^

Post Reply

Who is online

Users browsing this forum: Google [Bot]