[SOLVED] Play the voice's MC based on their gender using Renpy's Automatic Voice function.
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.
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.
- alexei
- Regular
- Posts: 137
- Joined: Mon Sep 09, 2019 10:31 am
- Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
- Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
- Organization: Funigami
- itch: funigami
- Discord: alexei#5190
- Contact:
Re: Play voice's MC based on their gender.
I'll check out everything tonight and see what works! Thanks for your help, guys.
- alexei
- Regular
- Posts: 137
- Joined: Mon Sep 09, 2019 10:31 am
- Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
- Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
- Organization: Funigami
- itch: funigami
- Discord: alexei#5190
- Contact:
Re: Play voice's MC based on their gender.
Ok peeps,
I tested both and it seems that what Alouette suggested initially works perfectly fine!
The Callback function doesn't work, the following exception occurs.
But I'm so glad that you helped me find a solution to this! I'll mark this as resolved, and I hope future programmers find it useful!
I tested both and it seems that what Alouette suggested initially works perfectly fine!
Code: Select all
define mc = Character("Main Character", voice_tag="mc_voice")
default gender = "female" # or "male"
init python:
def genderVoice(id):
global gender
voice_tag = _voice.tag
if voice_tag == "mc_voice":
return "voice/{}/{}.ogg".format(gender, id)
return "voice/{}.ogg".format(id)
config.auto_voice = genderVoiceCode: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/assets.rpy", line 2, in script
define y = Character("You", callback=genderVoice)
File "game/assets.rpy", line 2, in script
define y = Character("You", callback=genderVoice)
File "game/assets.rpy", line 2, in <module>
define y = Character("You", callback=genderVoice)
NameError: name 'genderVoice' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "renpy/bootstrap.py", line 274, in bootstrap
renpy.main.main()
File "renpy/main.py", line 558, in main
renpy.game.context().run(node)
File "game/assets.rpy", line 2, in script
define y = Character("You", callback=genderVoice)
File "game/assets.rpy", line 2, in script
define y = Character("You", callback=genderVoice)
File "renpy/ast.py", line 2441, in execute
self.set()
File "renpy/ast.py", line 2455, in set
value = renpy.python.py_eval_bytecode(self.code.bytecode)
File "renpy/python.py", line 1073, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/assets.rpy", line 2, in <module>
define y = Character("You", callback=genderVoice)
NameError: name 'genderVoice' is not defined
Windows-10-10.0.19041 AMD64
Ren'Py 7.5.1.22070801
ReShape 0.93
Mon Jul 25 12:02:24 2022
Who is online
Users browsing this forum: No registered users
