[Solved..?] Question about bars

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.
Post Reply
Message
Author
User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

[Solved..?] Question about bars

#1 Post by Lezalith » Fri Sep 30, 2016 7:21 pm

Hi everyone, I hope you're having a fantastic day.

Let's say we have a bar. This bar is long 820px and has range of 100. It indicates a variable that has a minimum of 0 and maximum of 100.

The way I imagined this to work is that range is going to be the maximum value of variable (100). Each time the value would increase by, let's say, 10, the bar would grow by 82px, up to the maximum of value = 100 and bar length of 820px.

It even sounds logical. Why does my bar reach the maximum length of 820 when the value is about 65 out of 100?
Last edited by Lezalith on Sat Oct 01, 2016 8:11 am, edited 1 time in total.

User avatar
gas
Miko-Class Veteran
Posts: 838
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Question about bars

#2 Post by gas » Fri Sep 30, 2016 7:22 pm

Post your code and let's see!
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Re: Question about bars

#3 Post by Lezalith » Fri Sep 30, 2016 7:34 pm

Code: Select all

        bar:
            xpos 391
            ypos 50
            ysize 50
            value AnimatedValue(value=skillValueNew, old_value=skillValueOld, delay=2, range=100)
            left_bar "screens/teaching/teaching_baronly.png"
            right_bar "GUI/Config/empty.png"
            thumb None
The skillValueNew and skillValueOld come from many different calculations, all of them work the same, however. Here is one of them, although don't think that's where the issue is.

Code: Select all

        $ skillValueOld = LeadershipValue
        $ MoodAffection = (- MoodAfraid + MoodPressured)
        if MoodAffection > 0:
            $ MoodAffection = MoodAffection + 2
        else:
            pass
        $ TeachingPoints = (MoodAffection + 6)*1.66667
        $ LeadershipValue = (skillValueOld + TeachingPoints)
        $ LeadershipValue = round(LeadershipValue, 3)
        $ skillValueNew = LeadershipValue
Just in case someone can't read that, it basically stores LeadershipValue in skillValueOld, then takes TeachingPoints (Which is a combination of base value of 1.66667 plus MoodAffection) and adds them to the skillValueOld, creating a new value for LeadershipValue. This is then stored in skillValueNew purely for the purpose of animated bar.

This math stuff is actually done right (and always) before the bar is shown.

User avatar
gas
Miko-Class Veteran
Posts: 838
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Question about bars

#4 Post by gas » Fri Sep 30, 2016 8:08 pm

Try something like (it worked for me)

Code: Select all

 
    $ mybar=AnimatedValue(value=skillValueNew, old_value=skillValueOld, delay=2, range=100)
    bar value mybar xalign 0.5 yalign 0.1 xsize 820 #and other style stuff
If that doesn't work, there's surely something wrong with the math (tried the variable inspector?)
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Re: Question about bars

#5 Post by Lezalith » Sat Oct 01, 2016 8:11 am

Didn't work for me.

But hey, this is weird:
I went to check how long actually is the added part of the bar, it says 134px.
Then I went on and recreate the bar with the same values into a new project, and it added 86px.

Then I had the idea of adding xmaximum. That shouldn't do much, because the teaching_baronly.png is of the exact needed width, but it changed the 134px to 88px. And I think I'll go with that, Because now it's only about 60px off of what it should be, but since it's an animated bar it's not all that recognizable.

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_