[Tutorial]Adding a Love Meter Bar

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Message
Author
User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#16 Post by OokamiKasumi »

sapiboonggames wrote:Will this code work if I change the shape of the bar?
I want to make it the shape of heart and has been wondering if this code will work as well.
Thanks! :)
I don't see why it wouldn't work?
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
BlueJayGames
Newbie
Posts: 7
Joined: Sat Jan 04, 2014 7:26 pm
Organization: Blue Jay Games
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#17 Post by BlueJayGames »

This is very helpful! Thank you. :) I'm making a transition from actionscript 3 over to ren'py/python and your tutorials are all very helpful.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#18 Post by OokamiKasumi »

BlueJayGames wrote:This is very helpful! Thank you. :)
-- My pleasure. I love being helpful. ♥
I'm making a transition from actionscript 3 over to ren'py/python and your tutorials are all very helpful.
Renpy is far more user friendly than it looks!
-- The support is awesome too!
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

Zalkyria
Regular
Posts: 36
Joined: Mon Jan 28, 2013 7:39 pm
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#19 Post by Zalkyria »

Hi again, I have question. I have two events going on and I wanted it to be depending how high or low you got the girl to be at, would trigger either of the two events. One being good the other being bad. Is there anyway to link it with the if statments?
Currently working on Dance With Me? - Danny Phantom Date Sim.
Link to our blog - http://dpdatesim.tumblr.com/
Currently looking for writers, and help with coding on the game. Please contact me or JaxxyLupei, on here or message on the blog.

User avatar
HB38
Regular
Posts: 57
Joined: Sun Apr 27, 2014 2:14 pm
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#20 Post by HB38 »

Zalkyria wrote:Hi again, I have question. I have two events going on and I wanted it to be depending how high or low you got the girl to be at, would trigger either of the two events. One being good the other being bad. Is there anyway to link it with the if statments?
Sure can - you can even have multiple levels too:

Code: Select all


if (person_love >= 75):
     *EVENT ONE*
elif (person_love >= 50):
    *EVENT TWO*
else:
    *BAD EVENT*

Super stripped down to the basics; but will get a different event depending on the love levels. Feel free to remove the 'elif' event too.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#21 Post by OokamiKasumi »

HB38 wrote:
Zalkyria wrote:Hi again, I have question. I have two events going on and I wanted it to be depending how high or low you got the girl to be at, would trigger either of the two events. One being good the other being bad. Is there anyway to link it with the if statments?
Sure can - you can even have multiple levels too... Super stripped down to the basics; but will get a different event depending on the love levels. Feel free to remove the 'elif' event too.
Renpy reads code from Top to Bottom; it will always check the Top event to see if it's False before it checks the next, so make sure you label the options in a way that they only pick One event not Two, or even Three.

Code: Select all

Label Events_End: 
    if (person_love >= 75):
         jump EVENT_ONE

    elif (person_love >= 50):
        jump EVENT_TWO

    else:
        jump BAD_EVENT
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#22 Post by noeinan »

Thanks for the great tutorial, OokamiKasumi! After experimenting with this code, and looking at the code over here: http://lemmasoft.renai.us/forums/viewto ... 51&t=16273 I think I have figured out how to include a bar.

There was one thing I was curious about, though. What is the thumb.png for? When I tried incorporating thumb.png, I ended up with a bar that only increased by the tiniest sliver during love gain. I ran myself around in circles trying to figure out how to fix it, and what the thumbs.png/thumb_offset did before looking at another bar and realizing I could set thumb to None-- and then suddenly my bar started working perfectly.

The only thing I can think of is... The thumb might be a way of adding a different color or shadow onto the end of the bar, so it doesn't just cut off with a straight line of disappeared pixels? (I'm using a plain single color bar at the moment, so I didn't implement that kind of feature.)
Attachments
bar_full.png
bar_full.png (828 Bytes) Viewed 2863 times
bar_hover.png
bar_hover.png (820 Bytes) Viewed 2863 times
bar_empty.png
bar_empty.png (840 Bytes) Viewed 2863 times
thumb.png
thumb.png (309 Bytes) Viewed 2863 times
Image

Image
Image

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#23 Post by OokamiKasumi »

daikiraikimi wrote:Thanks for the great tutorial, OokamiKasumi! ...There was one thing I was curious about, though. What is the thumb.png for?
The thumb.png is the tiny graphic that moves on a Slider bar to allow the player to adjust the settings.
slider.jpg
slider.jpg (43.98 KiB) Viewed 2846 times
Because I tend to use the same bars for Preferences --which use a thumb.png-- I tend to include it.
bar_empty.png
bar_empty.png (3.14 KiB) Viewed 2847 times
bar_full.png
bar_full.png (10.88 KiB) Viewed 2847 times
bar_hover.png
bar_hover.png (11.29 KiB) Viewed 2847 times
thumb.png
thumb.png (3.85 KiB) Viewed 2847 times
Sorry if I confused you there.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#24 Post by noeinan »

Ooooh, that makes sense. :) Thanks!
Image

Image
Image

JaxxyLupei
Regular
Posts: 30
Joined: Tue Apr 08, 2014 10:34 pm
Projects: Dance With Me? (A date sim)
Location: NY

Re: [Tutorial]Adding a Love Meter Bar

#25 Post by JaxxyLupei »

Okay, I keep looking this over and over but there's no explanation as to how to incorporate the actual frame image into the coding for it to show up. Can you explain that to me please?

User avatar
HimawariChiyako
Newbie
Posts: 22
Joined: Thu Nov 27, 2014 6:35 am
Completed: (Already have few, but all screwed.) --
Projects: (Too Many.)
Organization: --
Deviantart: ChichinashiMizuko
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#26 Post by HimawariChiyako »

I did as you said, but i keep getting errors.
File "game/script.rpy", line 59: expected statement
show_giselle ->=True

File "game/script.rpy" , line 74: Line is indented, but the proceeding statement does not expect a block. Please check this line's indentation.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#27 Post by OokamiKasumi »

JaxxyLupei wrote:Okay, I keep looking this over and over but there's no explanation as to how to incorporate the actual frame image into the coding for it to show up. Can you explain that to me please?
The 'frame' used in the meter bar is the same frame used by the rest of the game.
You can change the frame by adding this in options.rpy:

Code: Select all

    style.frame.background = Frame("ui/YourFrameImage.png",5,5)
If you want a frame specific to only the meter bar, add this to the bottom of the Meter Bar code:

Code: Select all

    # custom frame
    style.my_frame.background = Frame("ui/YourFrameImage.png",5,5)
Then change this whole section to add the custom frames:

Code: Select all

    ## ------------ Love Points Floater ----------------------

    def stats_overlay():               
        
        # --- Giselle's Love Bar -------
        if show_giselle:
            ui.frame(
                xalign = 0.5, #centered
                ypos = 400, #400 px Down from the Top
                style="my_frame")
            
            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()
            
        # --- Arthur's Love Bar -------   
        if show_arthur:
            ui.frame(
                xalign = 0.5,
                ypos = 400,
                style="my_frame")
            
            ui.vbox()
            ui.text ("Arthur's Love Points: %d" %arthur_love, 
                xalign = 0.5)
            ui.bar(max_love, arthur_love, 
                style="my_bar")
            
            ui.close()
            
        # --- Shino's Love Bar -------   
        if show_shino:
            ui.frame(
                xalign = 0.5,
                ypos = 400,
                style="my_frame")
            
            ui.vbox()
            ui.text ("Shino's Love Points: %d" %shino_love, 
                xalign = 0.5)
            ui.bar(max_love, shino_love, 
                style="my_bar")
            
            ui.close()
           
    config.overlay_functions.append(stats_overlay)

In short, you create a style called my_frame, then you add it to each character's ui.vbox.
-- Make sure you pay close attention to your COMMAS!
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#28 Post by OokamiKasumi »

HimawariChiyako wrote:I did as you said, but i keep getting errors.

Code: Select all

 File "game/script.rpy", line 59: expected statement
   show_giselle ->=True

File "game/script.rpy" , line 74: Line is indented, but the proceeding statement does not expect a block. Please check this line's indentation.
This is an Indentation or Spacing error.
-- According to this error, you've indented line 74 and you shouldn't have.

How the code should look:

Code: Select all

    $ show_giselle=True
    pause 0.5
    $ giselle_love+=50
    
    #The Announcement Text for the Love Bar
    show expression Text("{color=ffffff}{font=fo/LHFmisterkookyREG_0.TTF}+50 Love Points{/font}{/color}", 
        size=50, 
        yalign=0.5, 
        xalign=0.5, 
        drop_shadow=(2, 2)) as text
    with dissolve
    
    $ show_giselle=True
    $ renpy.pause() #This keeps the bar visible until the player hits a key. 
    hide text with dissolve
    $ show_giselle=False
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
HimawariChiyako
Newbie
Posts: 22
Joined: Thu Nov 27, 2014 6:35 am
Completed: (Already have few, but all screwed.) --
Projects: (Too Many.)
Organization: --
Deviantart: ChichinashiMizuko
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#29 Post by HimawariChiyako »

OokamiKasumi wrote:
HimawariChiyako wrote:I did as you said, but i keep getting errors.

Code: Select all

 File "game/script.rpy", line 59: expected statement
   show_giselle ->=True

File "game/script.rpy" , line 74: Line is indented, but the proceeding statement does not expect a block. Please check this line's indentation.
This is an Indentation or Spacing error.
-- According to this error, you've indented line 74 and you shouldn't have.

How the code should look:

Code: Select all

    $ show_giselle=True
    pause 0.5
    $ giselle_love+=50
    
    #The Announcement Text for the Love Bar
    show expression Text("{color=ffffff}{font=fo/LHFmisterkookyREG_0.TTF}+50 Love Points{/font}{/color}", 
        size=50, 
        yalign=0.5, 
        xalign=0.5, 
        drop_shadow=(2, 2)) as text
    with dissolve
    
    $ show_giselle=True
    $ renpy.pause() #This keeps the bar visible until the player hits a key. 
    hide text with dissolve
    $ show_giselle=False
Okay, I'll check that out, Thank you. :)

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [Tutorial]Adding a Love Meter Bar

#30 Post by OokamiKasumi »

HimawariChiyako wrote:Okay, I'll check that out, Thank you. :)
Also, make sure you actually have the font used in the announcement messages. That will cough up errors too.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

Post Reply

Who is online

Users browsing this forum: No registered users