How do I display a bar's value? [Solved]

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
sandman12456
Newbie
Posts: 13
Joined: Sun May 15, 2016 5:30 pm
Contact:

How do I display a bar's value? [Solved]

#1 Post by sandman12456 »

I'm having a hard time figuring this out.

First of all here is a picture of what I am trying to do:

https://imgur.com/a/YWHMs

I've made a bar using the following code:

init:
$One = 0


hbox:
bar value VariableValue("One", 100):
xalign 0.0 yalign 0.0
xmaximum 400
ymaximum 15
left_bar Frame("gui/bar/left.png", 10, 0)
right_bar Frame("gui/bar/right.png", 10, 0)
thumb None
thumb_shadow None



The bar can slide with user input which is what I want, but I want to be able to display the number value of where the user slides the bar to.
Last edited by sandman12456 on Fri Sep 22, 2017 11:19 pm, edited 1 time in total.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: How do I display a bar's value?

#2 Post by Divona »

You could display variable value using text.

Code: Select all

    text "[One]"
Completed:
Image

sandman12456
Newbie
Posts: 13
Joined: Sun May 15, 2016 5:30 pm
Contact:

Re: How do I display a bar's value?

#3 Post by sandman12456 »

Hey thanks a lot that worked great! Do you happen to know how I can save the value? or should I start a new thread for that?

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: How do I display a bar's value?

#4 Post by Divona »

In your case, the value is already saved in variable name "One".

Code: Select all

init:
    default One = 0
Not really sure what these bars are for, but you could also use persistent variables to have them save across sessions.
Completed:
Image

sandman12456
Newbie
Posts: 13
Joined: Sun May 15, 2016 5:30 pm
Contact:

Re: How do I display a bar's value?

#5 Post by sandman12456 »

Thanks so much

sandman12456
Newbie
Posts: 13
Joined: Sun May 15, 2016 5:30 pm
Contact:

Re: How do I display a bar's value? [Solved]

#6 Post by sandman12456 »

I tried reading the persistent variables page you linked to figure it out but i'm a little confused on how I actually make these persistent?

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: How do I display a bar's value? [Solved]

#7 Post by Divona »

sandman12456 wrote: Sat Sep 23, 2017 5:28 pm I tried reading the persistent variables page you linked to figure it out but i'm a little confused on how I actually make these persistent?

Code: Select all

default persistent.One = 100

Code: Select all

hbox:

    bar:
        value FieldValue(persistent, "One", 100)
        xalign 0.0 yalign 0.0 
        xsize 400
        ysize 15
        left_bar Frame("gui/bar/left.png", 10, 0)
        right_bar Frame("gui/bar/right.png", 10, 0)
        thumb None
        thumb_shadow None
        
    text "[persistent.One]"
Completed:
Image

sandman12456
Newbie
Posts: 13
Joined: Sun May 15, 2016 5:30 pm
Contact:

Re: How do I display a bar's value? [Solved]

#8 Post by sandman12456 »

Perfect thank you so much for all of your help!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]