How do I implement the fight bar?
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.
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.
-
VisualLearning
- Newbie
- Posts: 12
- Joined: Thu Jan 07, 2016 4:30 am
- Contact:
How do I implement the fight bar?
I want to have a bar in the upper left corner that shows the value of a variable that takes an int.
I have seen how the tutorial does it but using the code gives me errors. I have looked at the Day Planner framework but don't know how to call the button or how to style it.
The closest thing I've found is here under bar:
http://www.renpy.org/doc/html/screens.html#bar
Copying the example under my init or start label does not work for me. So here are my very simple questions:
1. How do I style a bar that says "Strength" which shows a var strength out of max strength.
2. Please let me know exactly where I should put the code and under which files since this is a part of Ren'Py I am struggling with.
3. How do I call the bar and how do I remove it?
4. How do I update the bar as I update my var strength?
I have seen how the tutorial does it but using the code gives me errors. I have looked at the Day Planner framework but don't know how to call the button or how to style it.
The closest thing I've found is here under bar:
http://www.renpy.org/doc/html/screens.html#bar
Copying the example under my init or start label does not work for me. So here are my very simple questions:
1. How do I style a bar that says "Strength" which shows a var strength out of max strength.
2. Please let me know exactly where I should put the code and under which files since this is a part of Ren'Py I am struggling with.
3. How do I call the bar and how do I remove it?
4. How do I update the bar as I update my var strength?
Re: How do I implement the fight bar?
Here's a really great tutorial for a 'love' bar that should be easily modified to fit your needs - I used it for experience points previously, worked like a charm.
As for where to place the code; you can throw it pretty much anywhere - Ren'Py is pretty flexible in that the order in a document doesn't matter so much (outside of the labels themselves anyhow).
As for where to place the code; you can throw it pretty much anywhere - Ren'Py is pretty flexible in that the order in a document doesn't matter so much (outside of the labels themselves anyhow).
-
VisualLearning
- Newbie
- Posts: 12
- Joined: Thu Jan 07, 2016 4:30 am
- Contact:
Re: How do I implement the fight bar?
Thank you. How did you find the thread? Are there more like it?
I do not wish to use custom visuals but the existing game interface. Doesn't the game have a way to create bars? I thought it would be simple.
I still don't know how to style a bar, call it or have it go away. I don't know how to make it display values that it gets from a var. I have read the thread over and over again and still don't understand which parts of the code I need to use and how I can change it to fit my request.
Seeing how there is no deeper explanation of the code I do not know how to write my own adaptation from scratch.
I do not wish to use custom visuals but the existing game interface. Doesn't the game have a way to create bars? I thought it would be simple.
I still don't know how to style a bar, call it or have it go away. I don't know how to make it display values that it gets from a var. I have read the thread over and over again and still don't understand which parts of the code I need to use and how I can change it to fit my request.
Seeing how there is no deeper explanation of the code I do not know how to write my own adaptation from scratch.
Re: How do I implement the fight bar?
I found it via a quick search, but it's also located in the cookbook directory thread.
You can probably replicate the feature using solid colors and boxes, but I would imagine just whipping up very basic graphics would still be easier.
You'd want to place the bar on it's own screen and then call and hide the screen as needed. The tutorial uses a variable to pull ($ show_giselle=True) it back and forth which could also be handy, but I prefer using screens.
Looking over the code, there is already a bar present and it's taking the graphics and just "applying them" - I'm not super familiar with them (as I've always made my own graphics) but it may be possible to forgo that step.
As for reading the code… well, I guess I'll just answer the one question you mention (the displaying of vars). Here is the bit from that tutorial where it takes the values and applies them to the bar:
The area with ui.text is where it outputs the words, and %giselle_love is the variable (you'd use %current_strength here or whatever your var is called).
The area with ui.bar has the values of %max_love (the maximum the bar can get to), and %giselle_love (which is the value of the stat). You'd probably change those to %max_strength and %current_strength for your code.
The rest of the code is for just where it's being displayed on the page, if you're unsure what it's doing I'd just change one value and a time and reload your project (shift - R if developer mode is on) to see where things move and go from there.
…
If you feel truly lost, I would recommend creating a new project and copy/pasting the entire tutorial in there, run it… then just start changing things. At least, that's how I work best.
You can probably replicate the feature using solid colors and boxes, but I would imagine just whipping up very basic graphics would still be easier.
You'd want to place the bar on it's own screen and then call and hide the screen as needed. The tutorial uses a variable to pull ($ show_giselle=True) it back and forth which could also be handy, but I prefer using screens.
Looking over the code, there is already a bar present and it's taking the graphics and just "applying them" - I'm not super familiar with them (as I've always made my own graphics) but it may be possible to forgo that step.
As for reading the code… well, I guess I'll just answer the one question you mention (the displaying of vars). Here is the bit from that tutorial where it takes the values and applies them to the bar:
Code: Select all
def stats_overlay():
# --- Giselle's Love Bar -------
if show_giselle:
ui.frame(
xalign = 0.5, #centered
ypos = 400,) #400 px Down from the Top
ui.vbox(xalign = 0.5)
ui.text ("Giselle's Love Points: %d" %giselle_love,
xalign = 0.5)
ui.bar(max_love, giselle_love,
style="my_bar")
ui.close()
The area with ui.bar has the values of %max_love (the maximum the bar can get to), and %giselle_love (which is the value of the stat). You'd probably change those to %max_strength and %current_strength for your code.
The rest of the code is for just where it's being displayed on the page, if you're unsure what it's doing I'd just change one value and a time and reload your project (shift - R if developer mode is on) to see where things move and go from there.
…
If you feel truly lost, I would recommend creating a new project and copy/pasting the entire tutorial in there, run it… then just start changing things. At least, that's how I work best.
Re: How do I implement the fight bar?
Did some more digging, here is a bar using the built in methods that may be a bit easier for you to modify.
-
VisualLearning
- Newbie
- Posts: 12
- Joined: Thu Jan 07, 2016 4:30 am
- Contact:
Re: How do I implement the fight bar?
Good advice regarding creating a new project but sometimes I get confused about how to even implement the code.
The second thread was perfect. The code is simple and I clearly understand what each part does which helped me create what I wanted.
I really appreciate your help and patience!
The second thread was perfect. The code is simple and I clearly understand what each part does which helped me create what I wanted.
I really appreciate your help and patience!
Re: How do I implement the fight bar?
I'm not really a coder myself (and am more of a visual learner, actually… so har!) so seeing code and then monkeying with it is how I tend to work things out myself. Glad that was what you were looking for!VisualLearning wrote:Good advice regarding creating a new project but sometimes I get confused about how to even implement the code.
The second thread was perfect. The code is simple and I clearly understand what each part does which helped me create what I wanted.
I really appreciate your help and patience!
Who is online
Users browsing this forum: Ocelot