Ren'Py Dialogue box opacity slider.

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,422
4,275
This shouln't be an issue for Ren'Py. For screens it will just overwrite the existent one and replace it by the last that have been defined at this name.
This said, I haven't tried this when both screens are in the same file.
It turned out to be a second issue, the incorrect indentation of the other cut'n'paste
 

theyakuzi

Member
Jun 4, 2021
191
362
Both of the parts which must be edited are in the screens.rpy file

The first part is an edit of the "say" screen. This is the code that powers the dialogue box. You should compare it and edit so that it includes the relevant changes

The second part (after "# For preferences screen") is added to the "preferences" screen definition in the same file. You can add the snippet where you like in the screen.

If you don't know what "screen" means in renpy context, I suggest you research a bit more and/or come back and ask more questions.
I suppose this is outdated as i got a bunch of errors
 
  • Thinking Face
Reactions: osanaiko

theyakuzi

Member
Jun 4, 2021
191
362
Still working as of Ren'py 8.1.3. What errors are you getting?

View attachment 3964595

In your preferences screen:
View attachment 3964597


View attachment 3964606
1724547715650.png

1724547684693.png



I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 28, in script
e smile "Wake up little bro"
File "game/script.rpy", line 28, in script
e smile "Wake up little bro"
File "renpy/common/000window.rpy", line 132, in _window_auto_callback
_window_show(auto=True)
File "renpy/common/000window.rpy", line 75, in _window_show
renpy.with_statement(trans)
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,422
4,275
The python error states there is an attempted multiplication of a "float" and a "none". This is somewhere in the internals, but must be due to the parameter being passed in.

In the renpy in-game console, I can get the same error with this code:
Code:
> 1.0 * None
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'
Despite the default persistent.textbox_transparency = 1.0, it seems somehow there is a "none", i.e. an unset variable, involved somewhere.

Apart from that, scanning through the code the only difference i can see from the MissFortune example is you have 1 - persistent.textbox_transparency. That should not be an issue as long as the variable is a float; in python "1 - 1.0" gives "0.0" due to type coercion.

At this stage, I'd stop looking closely at this code and go back to basics here and recheck your assumptions - are you editing the right files? do you have code in another file that is overwriting a variable? Can you try deleting the RPYC files and see what happens? (although keep backups! if you are working on an existing game - it can cause issues with reloading save games from previous versions)
 

peterppp

Active Member
Mar 5, 2020
693
1,187
The python error states there is an attempted multiplication of a "float" and a "none". This is somewhere in the internals, but must be due to the parameter being passed in.

In the renpy in-game console, I can get the same error with this code:
Code:
> 1.0 * None
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'
Despite the default persistent.textbox_transparency = 1.0, it seems somehow there is a "none", i.e. an unset variable, involved somewhere.

Apart from that, scanning through the code the only difference i can see from the MissFortune example is you have 1 - persistent.textbox_transparency. That should not be an issue as long as the variable is a float; in python "1 - 1.0" gives "0.0" due to type coercion.

At this stage, I'd stop looking closely at this code and go back to basics here and recheck your assumptions - are you editing the right files? do you have code in another file that is overwriting a variable? Can you try deleting the RPYC files and see what happens? (although keep backups! if you are working on an existing game - it can cause issues with reloading save games from previous versions)
yeah something else must be going on because the error doesn't match any error you'd get from that line regardless of the value of persistent.textbox_transparency, or any of the other parameters.

edit: it's likely this line:
Code:
text what id "what" size persistent.text_pref_size
if persistent.text_pref_size doesn't exist/has a None value, you get that error. the editor in his screenshot even complains about that variable name, though donno if that's a coincidence
 
Last edited:
  • Like
Reactions: anne O'nymous

theyakuzi

Member
Jun 4, 2021
191
362
The python error states there is an attempted multiplication of a "float" and a "none". This is somewhere in the internals, but must be due to the parameter being passed in.

In the renpy in-game console, I can get the same error with this code:
Code:
> 1.0 * None
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'
Despite the default persistent.textbox_transparency = 1.0, it seems somehow there is a "none", i.e. an unset variable, involved somewhere.

Apart from that, scanning through the code the only difference i can see from the MissFortune example is you have 1 - persistent.textbox_transparency. That should not be an issue as long as the variable is a float; in python "1 - 1.0" gives "0.0" due to type coercion.

At this stage, I'd stop looking closely at this code and go back to basics here and recheck your assumptions - are you editing the right files? do you have code in another file that is overwriting a variable? Can you try deleting the RPYC files and see what happens? (although keep backups! if you are working on an existing game - it can cause issues with reloading save games from previous versions)
yeah something else must be going on because the error doesn't match any error you'd get from that line regardless of the value of persistent.textbox_transparency, or any of the other parameters.

edit: it's likely this line:
Code:
text what id "what" size persistent.text_pref_size
if persistent.text_pref_size doesn't exist/has a None value, you get that error. the editor in his screenshot even complains about that variable name, though donno if that's a coincidence
idk its a fresh project so i dont understand why, i'll try to figure it out somehow
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,422
4,275
Actually I think peterppp is correct.

I've got a fresh project here that I checked , and my "screen say(who, what):" definition does not have "size preferences.pref_text_size" in it. So when you've copied in the changes for the variable opacity dialogue background, you've accidentally pulled in another change from the default say screen at the same time.

If that particular variable was not defined at all, as in you don't have a default value for it nor do you have a preferences screen setting for it yet, then you'd get the sort of error that you are seeing.
 

theyakuzi

Member
Jun 4, 2021
191
362
Actually I think peterppp is correct.

I've got a fresh project here that I checked , and my "screen say(who, what):" definition does not have "size preferences.pref_text_size" in it. So when you've copied in the changes for the variable opacity dialogue background, you've accidentally pulled in another change from the default say screen at the same time.

If that particular variable was not defined at all, as in you don't have a default value for it nor do you have a preferences screen setting for it yet, then you'd get the sort of error that you are seeing.
I created a new project doing the same thing and i get the same error once i press START , i must be doing something wrong but not sure what

the very first script lightman shared worked for me but the other version that should be more suitable for textboxes that aren't fullscreen just doesn't

have you tried actually pressing start and it's still working for you?
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,422
4,275
I created a new project doing the same thing and i get the same error once i press START , i must be doing something wrong but not sure what

the very first script lightman shared worked for me but the other version that should be more suitable for textboxes that aren't fullscreen just doesn't

have you tried actually pressing start and it's still working for you?
Yes, it's a new game I'm working on every day. Yes, it starts fine.

I'd appreciate if you stopped questioning what *I* have done and look at your own code. *You* have a problem, I am generously trying to help.

Please re-read what I wrote above.

I'm using Renpy Version 8.2.3, and I checked the github Renpy repo and confirmed the file in question has not changed even in the latest version tag (8.3.1.x)

This is what the "screen say" looks like when unmodified:
Code:
screen say(who, what):
    style_prefix "say"
    window:
        id "window"
        if who is not None:
            window:
                id "namebox"
                style "namebox"
                text who id "who"
        text what id "what"

    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
Your screenshots above show that you've modified it from the default file.

The issue is very likely to be the change you have made to the text what id "what" line when you copied in the other person's code.
 
Last edited:

peterppp

Active Member
Mar 5, 2020
693
1,187
the very first script lightman shared worked for me but the other version that should be more suitable for textboxes that aren't fullscreen just doesn't
because lightman added the "size persistent.text_pref_size" part in the second version WHICH DOES NOT WORK unless you have that persistent variable declared. in other words, the second script bugs if you just copy it to a fresh project

just remove the "size persistent.text_pref_size" part and it will work

LightmanP you might wanna modify your otherwise very helpful script change to avoid others having this problem
 
Last edited:

theyakuzi

Member
Jun 4, 2021
191
362
because lightman added the "size persistent.text_pref_size" part in the second version WHICH DOES NOT WORK unless you have that persistent variable declared. in other words, the second script bugs if you just copy it to a fresh project

just remove the "size persistent.text_pref_size" part and it will work

LightmanP you might wanna modify your otherwise very helpful script change to avoid others having this problem
I see now, thanks for the help
 
  • Like
Reactions: peterppp

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,620
15,601
just remove the "size persistent.text_pref_size" part and it will work
Adding a define persistent.text_pref_size = 100 (or whatever size he want) would works too.

Generally, if there's an "incompatible type" error, and it involve "None" and a float or integer, it's a persistent value that haven't been declared.
 

BimboDuck

Newbie
Dec 17, 2023
15
7
screen say(who, what):
style_prefix "say"
$ l_alpha = 1 - persistent.dialogueBoxOpacity

window:
id "window"
background Image(im.Alpha("gui/textbox.png", l_alpha))

if who is not None:

window:
id "namebox"
style "namebox"
text who id "who"

text what id "what"

Why this code changes my textbox location
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,422
4,275
screen say(who, what):
style_prefix "say"
$ l_alpha = 1 - persistent.dialogueBoxOpacity

window:
id "window"
background Image(im.Alpha("gui/textbox.png", l_alpha))

if who is not None:

window:
id "namebox"
style "namebox"
text who id "who"

text what id "what"

Why this code changes my textbox location
First, please use "code" formatting style when posting code samples in this forum, it makes it easier to read and preserves spacing, which is important in renpy code.

Second:

You have added the line background Image(im.Alpha("gui/textbox.png", l_alpha)) to the "window" screen element.

This overrides the default setting for the window element's "background" property. The default is defined in the "style window" block in the screens.rpy file.

If you check that default you'll see it has positional properties on the background image:
Code:
style window:
    ... snip irrelevant properties ...
    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
So when you have overridden the property, you lose the xalign and yalign settings.

If you add those into your override it will retain the original position:
background Image(im.Alpha("gui/textbox.png", l_alpha), xalign=0.5, yalign=1.0)
 
  • Like
Reactions: BimboDuck

BimboDuck

Newbie
Dec 17, 2023
15
7
First, please use "code" formatting style when posting code samples in this forum, it makes it easier to read and preserves spacing, which is important in renpy code.

Second:

You have added the line background Image(im.Alpha("gui/textbox.png", l_alpha)) to the "window" screen element.

This overrides the default setting for the window element's "background" property. The default is defined in the "style window" block in the screens.rpy file.

If you check that default you'll see it has positional properties on the background image:
Code:
style window:
    ... snip irrelevant properties ...
    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
So when you have overridden the property, you lose the xalign and yalign settings.

If you add those into your override it will retain the original position:
background Image(im.Alpha("gui/textbox.png", l_alpha), xalign=0.5, yalign=1.0)
Thank you
 
  • Like
Reactions: osanaiko