Page 1 of 1

Two point system bars overlapping.

Posted: Sun May 07, 2017 11:53 am
by Dumptuous
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.

Re: Two point system bars overlapping.

Posted: Sun May 07, 2017 6:20 pm
by renpic
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! :)

Re: Two point system bars overlapping.

Posted: Sun May 07, 2017 7:25 pm
by Imperf3kt
I'd use a hbox or grid, instead of a vbox (v means vertical, up/down)

Re: Two point system bars overlapping.

Posted: Mon May 08, 2017 8:00 am
by Donmai
That's outdated code. Try screens language instead: https://www.renpy.org/doc/html/screens. ... n-language

Re: Two point system bars overlapping.

Posted: Wed May 10, 2017 5:58 pm
by renpic
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!