Costumizing my two health 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
maricore
Regular
Posts: 41
Joined: Fri Jan 22, 2016 5:48 pm

Costumizing my two health bars?!

#1 Post by maricore »

Okay, I have two health bars in my game, and vertical bars, I made a bar designs for them but I seriously don't know how to add them into renpy, also they both have two different designs, tutorials are old, tried a lot of them and end up with errors and no I don't know much about coding or python and yes I'm a newbie xD.
Does anyone have the latest version of renpy who can help?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Costumizing my two health bars?!

#2 Post by namastaii »


User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Costumizing my two health bars?!

#3 Post by namastaii »

And the creator commented on that post with a more updated version if you didn't see.

Code: Select all

screen thebar:
    bar value StaticValue(barvariable, 1000):
        xalign 0.0 yalign 0.0 
        xmaximum 400 
        ymaximum 15
        left_bar Frame("image.png", 10, 0) 
        right_bar Frame("image2.png", 10, 0)
        thumb "thumb.png" 
        thumb_shadow None
I haven't tried making custom bars yet and I may soon.

There is also this post that covers a lot of customization. Scroll down until you see "D. Styling Bars & Sliders"
http://lemmasoft.renai.us/forums/viewto ... f=8&t=9812

The code looks something like this:

Code: Select all

style.pref_slider.left_bar = "menu/bar_full.png"
style.pref_slider.right_bar = "menu/bar_empty.png"
style.pref_slider.hover_left_bar = "menu/bar_hover.png"
style.pref_slider.ymaximum = 29
style.pref_slider.xmaximum = 197

Code: Select all

style.pref_slider.thumb = "menu/thumb.png"

Code: Select all

style.pref_slider.thumb_offset = 6
Last edited by namastaii on Wed Feb 03, 2016 2:09 pm, edited 1 time in total.

maricore
Regular
Posts: 41
Joined: Fri Jan 22, 2016 5:48 pm

Re: Costumizing my two health bars?!

#4 Post by maricore »

I tried the codes but it doesn't work! Still errors...
I use the animated bar value instead of static and I have hbox thing...
When I write the left-bar code it tells me its not a bailed child for hbox.
Also I tried to copy and paste the code itself and edit it to my own art but it gave be a bunch of errors, something like expected statement thing...
I'm sorry I can't post a code, I can't have access to my laptop for a while.
What am I doing wrong?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Costumizing my two health bars?!

#5 Post by namastaii »

What screen language are you wanting to use? the ui. one or the more recent version of code?

Depending on my page in my game, I have it written either way lol It's pretty unorganized but I know some styles for certain things better than others. They just came out of habit.

I have custom bars in my game now, and I updated the preference bars the way I showed you in the code and that worked. Other than that, I've simply just been typing out the bar every time for stuff instead of making it a style.

It looks something like this:

Code: Select all

ui.bar(range=the_max_range,value=the_value_thebarismeasuring,xmaximum=300,left_bar=Frame("full_bar.png"),right_bar=Frame("empty_bar.png"),thumb="thumb.png"xpos=100,ypos=100)
or you can write it like this (the one above requires an init python)

Code: Select all

bar range the_max_range value the_value_thebarismeasuring xmaximum 300 left_bar Frame("full_bar.png") right_bar Frame("empty_bar.png") thumb None xpos 100 ypos 100
These should work and writing out a style should be able to work too. after you write 'bar' and the maximum and value, you should be able to type style after it with something like: style "my_bar"

With a style formatted like this:

Code: Select all

style.my_bar.left_bar = "bar_full.png"
style.my_bar.right_bar = "bar_empty.png"
#style.my_bar.hover_left_bar = "bar_hover.png" ##I don't know, I don't use this
style.my_bar.ymaximum = 30
style.my_bar.xmaximum = 200

Code: Select all

bar range the_max_range value the_value style "my_bar"

maricore
Regular
Posts: 41
Joined: Fri Jan 22, 2016 5:48 pm

Re: Costumizing my two health bars?!

#6 Post by maricore »

The first and last lines of codes didn't work...
So I tried without them
http://sta.sh/01vmo0l2a6q7
http://sta.sh/016yrbroxfvb
http://sta.sh/014qbd05oaqo
See that last error with the style? It keeps giving it to me no matter where or how I put this line anywhere!
And I apologize if I made an obviouse mistake there but again I'm a total noob as u can see -_-

User avatar
Vaendryl
Regular
Posts: 39
Joined: Thu Dec 26, 2013 10:10 pm
Projects: Sunrider
Organization: Love in Space
IRC Nick: vaendryl
Contact:

Re: Costumizing my two health bars?!

#7 Post by Vaendryl »

I'm not sure what you're doing with the style lines inside the screen, but it seems it crashes without a $ in front of them denoting they're not screen language but python lines. I don't think they should be there at all, though.
then again, I know nothing about styles as I never use them :/

I'm also not really sure what the first error is about

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Costumizing my two health bars?!

#8 Post by namastaii »

your syntax is wrong. Which means you have indentation errors and you're putting things under init python when it shouldn't be and vice versa.

So what you should try doing is, in your script.rpy (before the rest of your code) at the top put 'init python:'

then define the style.conceal bar there just like you did. THEN with your bar, wherever you decide to put it. That's when you use the bar code. Not under the style definition because that isn't python code, it's ren'py code. Just put that bar or ui.bar code even, where you need it whether it be a screen or a page etc.

And it'll be in a format like this:

bar range the_max_range value the_value style "conceal_bar"

like you did before. Though you don't have to define your variables as 'the_max_range' or 'the_value', I was just using that as an example. the_max_range should be defined somewhere and so should the_value. The value is the variable that is going to change over time and the max is obviously the max number/length of the bar.

#define variables somewhere
$ the_max_range = 10
$ the_value = 0
label new_scene:
show screen_with_your_bar
d "blah blah blah add one point to the value"
$ the_value += 1
d "Now the bar should show 1/10 instead of 0/10"

(keep in mind that this isn't indented right obviously, I just typed it up on here from scratch so the indentation wasn't included)

the screen is probably going to look something like:

screen my_bar:

vbox xpos 20 ypos 5:
bar range the_max_range value the_value style "conceal_bar"

(very simplified version) and no indentation in that either.

I hope this makes sense.. lol

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Costumizing my two health bars?!

#9 Post by namastaii »

basically what I'm saying is you can't define the styles inside the screen. Sorry if I was confusing from the start. If you're still having trouble, feel free to message me and send me over the file(s) and I'll set it up for you.

maricore
Regular
Posts: 41
Joined: Fri Jan 22, 2016 5:48 pm

Re: Costumizing my two health bars?!

#10 Post by maricore »

Okay almost there only one error for the max rage (the on you said you didn't put indentation in it)
http://sta.sh/013mpbep511p
Tried to put the brackets after and before the equal mark, didn't work.
But hey! No errors for any of above that! So I'm doing it right :) I think...
And its fine I understand now no styles in screen :)
And no you probably weren't confusing, I'm the one who didn't get it xD

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Costumizing my two health bars?!

#11 Post by namastaii »

Image

You have a space, it seems, between 'the' and '_max' lol

maricore
Regular
Posts: 41
Joined: Fri Jan 22, 2016 5:48 pm

Re: Costumizing my two health bars?!

#12 Post by maricore »

Okay soooo I did the space but then the entire screen turned gray and written on top the name of the bar, I didn't know what I was doing wrong.
But then I decided to try the init python thing with styles on the real game.
And it showed the bar! Just had to tweak some stuff here and there in my old code and it worked! Then I realised that the bar is not sliding which later on turned out that I NEED to have a thumb style in my init python and it worked perfectly!.
Here is the code if you are asking how it looks (sorry if it doesn't look clear I have a bad camera)
http://sta.sh/01qotekhizt8
I'll post this as a tutorial later on so people won't spin thier heads too much ^^"

Post Reply

Who is online

Users browsing this forum: AWizardWithWords, Majestic-12 [Bot], NeonNights, piinkpuddiin