Ren'Py animated bar troubleshooting [Solved]

Lou111

Active Member
Jun 2, 2018
543
686
I have an animated bar that works perfectly until I hover over something or trigger some other variable that has no relation to the bar itself...
Then the bar flickers and jumps around like a hungry poodle. It looks ridiculous. I need Help.

Python:
label test_room:
    call screen main_screen()


screen main_screen():
    use random_screen
    use random_screen
    use timer_bar     #The bar in question is on this screen among other screens
    use random_screen
    use random_screen


screen timer_bar():
    $ timeout = renpy.random.randint(2,5)
    timer timeout action Jump("test_room")
    if bar_show and persistent.timed_choices:
        vbar:
            xalign 1.0
            yalign .5
            xsize 25
            value AnimatedValue(old_value=0.0, value=1.0, range=1.0, delay=timeout)
Friends,
It's been just shy of 48 hours and I can't find a solution. I've tried pauses, manipulating static value bars, while loops, and typing profanity right into the code. Please help, or even tell me that it's impossible so I can move on with my life. Thanks all.
 

Lou111

Active Member
Jun 2, 2018
543
686
The solution I'm trying now is to create a variable that inverts the value of the timer and use it as the old_value.

Python:
timer timeout
$ base_value = timeout - float(timer)
vbar:
    value AnimatedValue(old_value=base_value, value=1.0, range=1.0, delay=timeout)
This way, the bar will pick up where it left off if the values refresh for some outside reason. But...
1. I don't know how to convert a timer into a float
2. It probably still won't work...
 

AnimeKing314

Giant Perv
Game Developer
Jun 28, 2018
395
605
The only thing I can think of is maybe trying to use xpos and xpos for the bar position rather than xalign and yalign. This probably won't work though because I can't see why it would make a difference but it's worth trying. Also make sure there's no overlap between hover spots and the bar itself. Other than that, seems to be a good guide for making timed choices. Not sure if any of this will help but it's the best I can offer right now.
 
  • Like
Reactions: Lou111

CocoVC

Newbie
Aug 10, 2018
76
170
What is the timed bar used for? Is it just for timed choices only?
What is the default value for the timeout variable?
 
  • Like
Reactions: Lou111

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
Then the bar flickers and jumps around like a hungry poodle. It looks ridiculous.
According to your code, the bar is simply put in the flow of the screen, positioned depending of the size of whatever is displayed above it. Therefore, it's natural that, when this size is changed, the bar is moved accordingly.
Putting the bar in a frame that you'll position explicitly with at least ypos (since the problem is the vertical position) should solve the problem.
 
  • Like
Reactions: Lou111

Lou111

Active Member
Jun 2, 2018
543
686
xpos and xpos for the bar position rather than xalign and yalign.
herefore, it's natural that, when this size is changed, the bar is moved accordingly.
The position of the bar itself isn't the issue, its the animation. The start or min value of the progress bar animation is being reset or manipulated.
What is the timed bar used for? Is it just for timed choices only?
Its simply a progress bar that represents the time remaining before the "real" timer jumps to a new screen label.

Here is what I'm lookin at:
You don't have permission to view the spoiler content. Log in or register now.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
The position of the bar itself isn't the issue, its the animation. The start or min value of the progress bar animation is being reset or manipulated.
Oh, yeah, I see it now:

Python:
screen timer_bar():
    $ timeout = renpy.random.randint(2,5) # <-----
    timer timeout action Jump("test_room")
    if bar_show and persistent.timed_choices:
        vbar:
            xalign 1.0
            yalign .5
            xsize 25
            value AnimatedValue(old_value=0.0, value=1.0, range=1.0, delay=timeout)
The value of timeout is computed every single time the screen is refreshed. And the screen is refreshed anytime there's an interaction or a change in "main_screen" the screen.

Replacing $ timeout = renpy.random.randint(2,5) by default timeout = renpy.random.randint(2,5) should solve the problem. Else you'll have to rely on a parameter:
Code:
label test_room:
    call screen main_screen( renpy.random.randint(2,5) )


screen main_screen( timeout ):
    use random_screen
    use random_screen
    use timer_bar( timeout )
    use random_screen
    use random_screen


screen timer_bar( timeout ):
    timer timeout action Jump("test_room")
    if bar_show and persistent.timed_choices:
        vbar:
            xalign 1.0
            yalign .5
            xsize 25
            value AnimatedValue(old_value=0.0, value=1.0, range=1.0, delay=timeout)
 
  • Like
Reactions: adickus and CocoVC

Lou111

Active Member
Jun 2, 2018
543
686
Oh, yeah, I see it now:

Python:
screen timer_bar():
    $ timeout = renpy.random.randint(2,5) # <-----
    timer timeout action Jump("test_room")
    if bar_show and persistent.timed_choices:
        vbar:
            xalign 1.0
            yalign .5
            xsize 25
            value AnimatedValue(old_value=0.0, value=1.0, range=1.0, delay=timeout)
The value of timeout is computed every single time the screen is refreshed. And the screen is refreshed anytime there's an interaction or a change in "main_screen" the screen.

Replacing $ timeout = renpy.random.randint(2,5) by default timeout = renpy.random.randint(2,5) should solve the problem. Else you'll have to rely on a parameter:
Code:
label test_room:
    call screen main_screen( renpy.random.randint(2,5) )


screen main_screen( timeout ):
    use random_screen
    use random_screen
    use timer_bar( timeout )
    use random_screen
    use random_screen


screen timer_bar( timeout ):
    timer timeout action Jump("test_room")
    if bar_show and persistent.timed_choices:
        vbar:
            xalign 1.0
            yalign .5
            xsize 25
            value AnimatedValue(old_value=0.0, value=1.0, range=1.0, delay=timeout)
I'm going to name my child after you. Thank you thank you.
AnimeKing314 CocoVC thank you for your replies