[bug] updating persistent value (background alpha)

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
jeffster
Veteran
Posts: 383
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

[bug] updating persistent value (background alpha)

#1 Post by jeffster »

It seems to be a bug in 7.4.2, as this code works well in 7.3.5:

I want to change the "say" ("window") background transparency via a custom slider and/or a Preference slider.

(I adopted this code from someone else's game).

Code: Select all

define persistent.say_window_alpha = 0.8

screen say(who, what):
    style_prefix "say"

    window:
        background Transform(style.window.background, alpha=persistent.say_window_alpha)
        #...The slider:
        vbar value FieldValue(persistent, 'say_window_alpha', 1.0, max_is_zero=False, offset=0, step=0.1):
            top_bar "gui/slider/vertical3_idle_bar.png"
            bottom_bar  "gui/slider/vertical3_hover_bar.png"
            thumb "gui/slider/thumb_idle.png"
            hover_thumb "gui/slider/thumb_hover.png"
            align (0.997, 0.99)
            xysize (40, 150)
            thumb_offset 10
Now in 7.4.2 the background is correct at the start of the game, i.e. if in the previous session I set alpha 1 or 0, the background (gui/textbox.png) is opaque or transparent.

But when I change the value of alpha via sliders, the value itself changes but the transparency of the background does not.

In 7.3.5 I could see how the box becomes transparent and vice versa, dragging the slider's thumb.

jeffster
Veteran
Posts: 383
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: [bug] updating persistent value (background alpha)

#2 Post by jeffster »

And it works properly if instead of assigning the persistent value I use an intermediary variable:

Code: Select all

    style_prefix "say"
    $ bugTest = persistent.say_window_alpha

    window:
#        background Transform(style.window.background, alpha=persistent.say_window_alpha)
        background Transform(style.window.background, alpha=bugTest)

JeffSevenDee
Newbie
Posts: 7
Joined: Fri Apr 10, 2020 2:46 pm
Projects: Coding my wife's project
Contact:

Re: [bug] updating persistent value (background alpha)

#3 Post by JeffSevenDee »

I confirm both the bug and the workaround
There is a screen that I use to display a x number of pictures based on persistent values in a for loop. When updating to 7.4.4, the screen would properly display the number of pictures, but will stay the same during the execution of the game, no matter the persistance changes. The workaround proposed by jeffster does work, i can confirm.

Code: Select all

screen show_keys():
    use GeneralScreenLook
    $ keyTotal = persistent.reading_keys

    vbox :
       frame:
         background "ruban.png"
         xpos 200
         ypos 400
         ymaximum 95
         xmaximum 310
         yfill True

         hbox:
           ypos 35
           xpos 65
           spacing 50

           for i in range(0, keyTotal):
              imagebutton:
                 idle "gui/button/cle_idle.png"
                 hover "gui/button/cle_hover.png"
                 action [Function(DecrementTick), Function(AutoLoading), Return()]
Before declaring and using keyTotal as this:

Code: Select all

for i in range(0, keyTotal)
the code read as this :

Code: Select all

for i in range(0,  persistent.reading_keys)
The later code was constantly displaying the very first value when the game initially showed that screen. Even if the persistent evolved over time would not change the display

Post Reply

Who is online

Users browsing this forum: No registered users