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.
Hello. I'd like to create a slider for a variable I've called persistent.outlinealpha.
It's a float that takes an argument from 0.0 to 1.0 (defaulting at 0..
I would like to be able to mimic how the audio sliders currently are, but all I can see of their code is:
bar value VariableValue("persistent.outlinealpha", 1.0)
Ah, also, the variable, when changed from the slider, does not seem to save upon exiting and reopening the game, even though it should be persistent. Would you have any idea why that could be happening?
Just one more question: Is there a way to make this match the default look of Music Volume and Sound Volume?
There are pre-defined styles just below or above the screen you're currently at. You can use those to copy the style. Or you can just simply put your bar right next to the other bars so that it will also inherit the styles.
Ah, also, the variable, when changed from the slider, does not seem to save upon exiting and reopening the game, even though it should be persistent. Would you have any idea why that could be happening?
How are you using the variable? Take note also that persistent variables only get saved if the game is exited properly (thru the close button or popping the exit confirmation, etc.)
Just one more question: Is there a way to make this match the default look of Music Volume and Sound Volume?
There are pre-defined styles just below or above the screen you're currently at. You can use those to copy the style. Or you can just simply put your bar right next to the other bars so that it will also inherit the styles.
Ah, also, the variable, when changed from the slider, does not seem to save upon exiting and reopening the game, even though it should be persistent. Would you have any idea why that could be happening?
How are you using the variable? Take note also that persistent variables only get saved if the game is exited properly (thru the close button or popping the exit confirmation, etc.)
It's already next to the other bars, but it's not inheriting the styles for some reason. I would think it's because it uses VariableValue instead of Preference? But with Preference, I couldn't get it to work.
vbox:
if config.has_music:
label _("Music Volume")
hbox:
bar value Preference("music volume")
if config.has_sound:
label _("Sound Volume")
hbox:
bar value Preference("sound volume")
if config.sample_sound:
textbutton _("Test") action Play("sound", config.sample_sound)
if config.has_music or config.has_sound or config.has_voice:
null height gui.pref_spacing
textbutton _("Mute All"):
action Preference("all mute", "toggle")
style "mute_all_button"
label _("Sprite Outlines")
hbox:
bar value VariableValue("persistent.outlinealpha", 1.0)
This is how it looks within my preferences screen at the moment.
There are pre-defined styles just below or above the screen you're currently at. You can use those to copy the style.
Move your cursor to the existing bar, then shift + i. You'll see the style that it uses. Now use that style in your bar.
I checked both the existing music slider, and my new slider.
My new slider is classified as "slider_bar" while the default music slider is "slider_slider".
How can I change it to match, within the code?
image big hello world = Text("Hello World", style="big")
screen hello_world:
text "Hello, World" style "big"
The music and sfx sliders don't have styles attached to them. And if the entire preferences screen did, shouldn't my bar automatically be adjusted by it?
There must be a way to use Preference() instead of VariableValue(), is there not? I tried doing some research but I couldn't find anything that helped me solve this. I tried attaching different styles to the current slider, tried attaching every style that's currently connected to the preference screen, but it stays the same each time I save and reload the game.
bar value VariableValue(...) style "slider_slider"
Check the style of the bar again using the inspector and see if the style of the bar really changed to "slider_slider". It should be since I tested this on a project myself.
enaielei wrote: ↑Mon Jul 17, 2023 5:33 pm
You already know that the existing bars use the style "slider_slider". And I sent the quote explaining how to use styles. So...
bar value VariableValue(...) style "slider_slider"
Check the style of the bar again using the inspector and see if the style of the bar really changed to "slider_slider". It should be since I tested this on a project myself.
Oh, that's my bad, I was adding a colon and then underneath adding style_prefix "slider_slider". This ended up working then, thank you for that, I really appreciate your help and patience!