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.
-
rinrin
- Veteran
- Posts: 211
- Joined: Thu Apr 16, 2009 9:18 am
- Completed: Several.
- Projects: Several.
-
Contact:
#1
Post
by rinrin » Thu Jun 21, 2012 11:18 am
I have a volume bar permanently displayed on the screen as part of the interface to make it more convenient for the player to change the volume at any time without having to go to the preference screen.

- volume.png (13.44 KiB) Viewed 597 times
Code: Select all
bar value Preference("music volume") range (80) xmaximum 80 ymaximum 10 thumb "soundbarthumb" thumb_shadow None thumb_offset 5 left_bar "soundbar_full" right_bar "soundbar_empty"
The problem is, it works for either only music or only sound effects and I want the player to be able to change the overall volume of the game (anything that makes a sound) with this slider (those who want more precise control could still access music and sound effects separately from the preferences screen).
Is there a way to have 'Music Volume' and 'Sound Volume' controlled by the same slider (setting two values to one bar)? Or is there some kind of an overall 'Volume' preference that affects all channels? Or some other method to achieve this?
Last edited by
rinrin on Thu Jun 28, 2012 6:42 am, edited 2 times in total.
-
Showsni
- Miko-Class Veteran
- Posts: 563
- Joined: Tue Jul 24, 2007 12:58 pm
-
Contact:
#2
Post
by Showsni » Thu Jun 21, 2012 12:04 pm
Hm. I have no real experience, but I guess you'd need to make your own adjustment. Here, let's try this...
In an init python block:
Code: Select all
init:
python:
def allvols(x):
_preferences.set_volume("sfx", x)
_preferences.set_volume("voice", x)
_preferences.set_volume("music", x)
allvolsad = ui.adjustment(range = 1.0, value = 1.0, changed=allvols)
Then for your bar (in screen language):
Code: Select all
bar value 1.0 range 1.0 adjustment allvolsad
Does that work? If I'm right, it should tie the music, sound effect and voice volume to the same bar.
-
rinrin
- Veteran
- Posts: 211
- Joined: Thu Apr 16, 2009 9:18 am
- Completed: Several.
- Projects: Several.
-
Contact:
#3
Post
by rinrin » Thu Jun 21, 2012 12:32 pm
Yes, it works!
Thank you!
-
rinrin
- Veteran
- Posts: 211
- Joined: Thu Apr 16, 2009 9:18 am
- Completed: Several.
- Projects: Several.
-
Contact:
#4
Post
by rinrin » Thu Jun 28, 2012 6:42 am
Update:
A strange bug occurs from time to time ever since I implemented that code. I can't reproduce it every time and have no idea what triggers it, so I'll just describe it: sometimes when I start the game, the volume bar (the one on the picture in the first post) is set to maximum, but no sound can be heard. If I move it a bit to the left, sound "activates" and works normally (doesn't stop if I pull the slider back to maximum).
It happened at least 3 times so far (not in the same session).
Does anyone have an idea what could be causing this and how to fix it?
Here's the code, just in case I implemented it wrong:
Code: Select all
init:
python:
def allvols(x):
_preferences.set_volume("sfx", x)
_preferences.set_volume("voice", x)
_preferences.set_volume("music", x)
allvolsad = ui.adjustment(range = 1.0, value = 1.0, changed=allvols)
bar (in screen language)
Code: Select all
bar value 1.0 adjustment allvolsad range (80) xmaximum 80 ymaximum 10 thumb "soundbarthumb" thumb_shadow None thumb_offset 5 left_bar "soundbar_full" right_bar "soundbar_empty"
Users browsing this forum: Bing [Bot]