Changing the opacity of the Dialogue box with a Slider
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.
Changing the opacity of the Dialogue box with a Slider
Hello, Guys! I'm a renpy noob and I'm working on changing the textbox with the help of a slider in the preference screen. I saw a code for it in a blog and copied it and pasted it. And now I can see a slider in the preference screen but when I move the thumb the opacity is not changing.
This code anywhere on the option.rpy
define persistent.dialogueBoxOpacity = 1.0
This code on the preference screen
label _("Dialogue box opacity")
bar value FieldValue(persistent, "dialogueBoxOpacity", range=1.0, style="slider")
And finally, this code under the say screen
window background Transform(Frame("gui/textbox.png",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
This is the blog from where I got this code and anyone new can visit this and copy the code and hopefully the answers here also make this code work. https://www.emolgatorium.com/blog/how-d ... -in-renpy/
Thank you!
This code anywhere on the option.rpy
define persistent.dialogueBoxOpacity = 1.0
This code on the preference screen
label _("Dialogue box opacity")
bar value FieldValue(persistent, "dialogueBoxOpacity", range=1.0, style="slider")
And finally, this code under the say screen
window background Transform(Frame("gui/textbox.png",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
This is the blog from where I got this code and anyone new can visit this and copy the code and hopefully the answers here also make this code work. https://www.emolgatorium.com/blog/how-d ... -in-renpy/
Thank you!
-
cheonbyeol
- Regular
- Posts: 37
- Joined: Thu Feb 04, 2021 9:04 am
- Contact:
Re: Changing the opacity of the Dialogue box with a Slider
My first guess is that you define the variable rather than defaulting it, so Ren'Py is not updating it
Programmer @ Celestea Productions

NaNo demo out!
My code:
GalleryPlus - extending gallery functionality

NaNo demo out!
My code:
GalleryPlus - extending gallery functionality
Re: Changing the opacity of the Dialogue box with a Slider
That looks like it should work. To try to see why it's not, set
then restart your game and press shift-O to open the console.
enter
and see if the value is getting changed by your bar slider.
Code: Select all
define config.developer = Trueenter
Code: Select all
> persistent.dialogueBoxOpacity
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Re: Changing the opacity of the Dialogue box with a Slider
Your error does appear to be using `define` instead of `default` to declare your variable. I'm a little surprised, since I was under the impression that renpy didn't actually enforce that 'defined' variables could not be changed.
Is there something in renpy.store that does in fact mark 'defined' variable as constant? I can't find any real documentation of how renpy.store works.
Is there something in renpy.store that does in fact mark 'defined' variable as constant? I can't find any real documentation of how renpy.store works.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
- Contact:
Re: Changing the opacity of the Dialogue box with a Slider
if this is set in the `style window` inside `screens.rpy` then it won't since this only gets executed once (when the style is being defined during init).Code: Select all
background Transform(Frame("gui/textbox.png",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
you have to do it inside the `say` screen in `screens.rpy` not in the style.
so find that screen and in the `window` with `id 'window'`, add `background Transform(Frame("gui/textbox.png",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)`.
Also, its a common practice to use `default` statements on `persistent` variables.
Re: Changing the opacity of the Dialogue box with a Slider
Thank you for the reply. I just found out that the opacity does changes but the lowest opacity didn't make it invisible.zmook wrote: ↑Mon Feb 22, 2021 5:23 pmThat looks like it should work. To try to see why it's not, setthen restart your game and press shift-O to open the console.Code: Select all
define config.developer = True
enterand see if the value is getting changed by your bar slider.Code: Select all
> persistent.dialogueBoxOpacity
Last edited by Yuvan raj on Tue Feb 23, 2021 3:46 pm, edited 1 time in total.
Re: Changing the opacity of the Dialogue box with a Slider
Thank you for replying! It was already working, and I didn't notice it as the lowest value didn't make it fully transparent but just a little bit.hell_oh_world wrote: ↑Mon Feb 22, 2021 6:31 pmif this is set in the `style window` inside `screens.rpy` then it won't since this only gets executed once (when the style is being defined during init).Code: Select all
background Transform(Frame("gui/textbox.png",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)
you have to do it inside the `say` screen in `screens.rpy` not in the style.
so find that screen and in the `window` with `id 'window'`, add `background Transform(Frame("gui/textbox.png",xalign=0.5, yalign=1.0), alpha=persistent.dialogueBoxOpacity)`.
Also, its a common practice to use `default` statements on `persistent` variables.
Last edited by Yuvan raj on Tue Feb 23, 2021 3:45 pm, edited 1 time in total.
Re: Changing the opacity of the Dialogue box with a Slider
Thank you so much for the reply! Both works I but it won't become fully transparent so I didn't notice it before.cheonbyeol wrote: ↑Mon Feb 22, 2021 4:34 pmMy first guess is that you define the variable rather than defaulting it, so Ren'Py is not updating it
Last edited by Yuvan raj on Tue Feb 23, 2021 3:43 pm, edited 1 time in total.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
- Contact:
Re: Changing the opacity of the Dialogue box with a Slider
for the `alpha` property `0.0` means transparent, while `1.0` is opaque. So the `alpha` actually only takes values between `0.0` and `1.0`.
Also, no need to spam the same message to everyone who answered your question.
Also, no need to spam the same message to everyone who answered your question.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]