Two point system bars overlapping.

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
Dumptuous
Newbie
Posts: 1
Joined: Sun May 07, 2017 11:05 am
Contact:

Two point system bars overlapping.

#1 Post by Dumptuous » Sun May 07, 2017 11:53 am

Hi, new user here.

I'm trying to make a game with a few stats/points. I have programmed a working point system now thanks to this guide: https://www.renpy.org/wiki/renpy/doc/co ... _Inventory
(I used the "showaffection" code for an affection meter.)

Thing is: this works for one stat, if I use another one for money for example, the two stats overlap eachother.

Image
Here's a picture of what's the problem.

Now the question:
Is it possible to first of all seperate these two with the given code in the script.rpy
script:

init python:
showaffection= False
affection = 0
def display_affection():
if showaffection:
ui.frame()
ui.text("Affection: %d" %affection)
config.overlay_functions.append(display_affection)

Thanks in advance!

PS. If anyone has a good tutorial about how to code these two stats in the screens.rpy, could anyone please link me to that? I want to add some icons for example, I don't think that's an option with the code provided above.

renpic
Newbie
Posts: 19
Joined: Sat Apr 08, 2017 1:07 pm
Location: Europe
Contact:

Re: Two point system bars overlapping.

#2 Post by renpic » Sun May 07, 2017 6:20 pm

Dumptuous wrote:Hi, new user here.
PS. If anyone has a good tutorial about how to code these two stats in the screens.rpy, could anyone please link me to that? I want to add some icons for example, I don't think that's an option with the code provided above.
One possible way to do it.

We define two global variables for the health and mana, as an example:

Code: Select all

init python:
    health = 100
    mana = 50
We add a stats screen to screens.rpy:

Code: Select all

screen stats():
    frame:
        background Frame("gui/stats.png")
        xalign 0.0
        yalign 0.0
        xpos 10
        ypos 10

        vbox:
            text "H: [health]" size 30 color "#111"
            text "M: [mana]" size 30 color "#111"
The stats screen overlay will only show the values of the two global variables we defined before. I created a small image called "gui/stats.png" for the background of the stat box.

If you wanna replace the "H:" and "M:" text with an image, perhaps you can just use the image tag inline. Like this:

Code: Select all

            text "{image=mana.png} [mana]" size 30 color "#111"
Finally, in the code we can use our new screen overlay like this:

Code: Select all

    "Hi!"
    show screen stats
    e "Now I will take a bit of your health."
    $ health -= 50
    e "But I will add 25 points to your mana."
    $ mana += 25
    e "And finally we will hide the stat screen."
    hide screen stats
    e "THE END"
I hope it helps! :)

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Two point system bars overlapping.

#3 Post by Imperf3kt » Sun May 07, 2017 7:25 pm

I'd use a hbox or grid, instead of a vbox (v means vertical, up/down)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
Donmai
Eileen-Class Veteran
Posts: 1919
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: Two point system bars overlapping.

#4 Post by Donmai » Mon May 08, 2017 8:00 am

That's outdated code. Try screens language instead: https://www.renpy.org/doc/html/screens. ... n-language
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

renpic
Newbie
Posts: 19
Joined: Sat Apr 08, 2017 1:07 pm
Location: Europe
Contact:

Re: Two point system bars overlapping.

#5 Post by renpic » Wed May 10, 2017 5:58 pm

Imperf3kt wrote:I'd use a hbox or grid, instead of a vbox (v means vertical, up/down)
I don't know, I was trying to get that kind of box with the code example, so vertical made more sense for me.
See the screenshot of what I got :) [The background frame is horrible, I know :P I just made it very quickly]

In the case of money / affection level, probably I'd go for a horizontal strip at the top of the screen instead, as suggested!
Attachments
onscreen-stats.png
Onscreen stats
onscreen-stats.png (7.45 KiB) Viewed 673 times

Post Reply

Who is online

Users browsing this forum: Google [Bot]