question on displaying stats

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

question on displaying stats

#1 Post by bozance »

Hi,

I have another quick newbie question. I am interested in displaying some basic stats in one corner of the screen at all times (score, and some additional lite RPG stats--only 2 or 3 total). I've seen stuff about overlays as well as RPG frames but am not well versed in what to do.

I'd be interested in seeing a working example of what I would need to do. I'm trying to get things like the following to always appear:

Score: 4
Fear: 3 out of 6

That's pretty much it. Any insights would be greatly appreciated.

LordShiranai
Regular
Posts: 188
Joined: Wed Jul 07, 2010 5:49 pm
Completed: Mobile Food Madness, Super Otome Quest
Location: Pacific Northwest
Contact:

Re: question on displaying stats

#2 Post by LordShiranai »

The screen language for 6.11 makes this sort of thing easier than ever. Like overlays, screens will update data they reference, but they are a bit easier to put together.

In an init block, you can do something like this:

Code: Select all

init python:
    def scoreboard(**kwargs):
        ui.frame(xpos = 0, xanchor = 0, ypos = 0, yanchor = 0)
        ui.vbox()
        ui.text("Score: %d" % player_score)
        ui.text("Fear: %d / 6" % player_fear)
        ui.close()

    renpy.define_screen('scoreboard', scoreboard) 
Then, wherever you need to show the scoreboard, you can show the screen. For example, if I want to show it right at the beginning.

Code: Select all

label start:
    $ player_score = 0
    $ player_fear = 3
    show screen scoreboard
Just be sure to make sure the variables referenced in the function are initialized before showing the screen.
Don't Blame Me. I Voted for Vermin Supreme.

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: question on displaying stats

#3 Post by bozance »

Excellent, thanks. Do I need to use the "show" command for each label? Or is there a single-line method to make it display all the time?

LordShiranai
Regular
Posts: 188
Joined: Wed Jul 07, 2010 5:49 pm
Completed: Mobile Food Madness, Super Otome Quest
Location: Pacific Northwest
Contact:

Re: question on displaying stats

#4 Post by LordShiranai »

IIRC, by default, screens should remain visible until it they are explicitly hidden when they appear via show (I believe they will even persist through new scenes). So in general, you don't need to explicitly show one again when you jump to a label.
Don't Blame Me. I Voted for Vermin Supreme.

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: question on displaying stats

#5 Post by bozance »

A follow-up question... is there a way to just show scores in a margin on the right side of the page?

I ask because I'm writing in NVL mode. It would be nice to have the text going down the page and something always on the right, but I have no idea whether that is possible.

LordShiranai
Regular
Posts: 188
Joined: Wed Jul 07, 2010 5:49 pm
Completed: Mobile Food Madness, Super Otome Quest
Location: Pacific Northwest
Contact:

Re: question on displaying stats

#6 Post by LordShiranai »

bozance wrote:A follow-up question... is there a way to just show scores in a margin on the right side of the page?

I ask because I'm writing in NVL mode. It would be nice to have the text going down the page and something always on the right, but I have no idea whether that is possible.
I haven't experimented with screens and NVL mode, but it should be possible. You can put any displayable, including elements of screens, wherever you want by adjusting the xpos, ypos, xanchor, and yanchor.
Don't Blame Me. I Voted for Vermin Supreme.

bozance
Regular
Posts: 61
Joined: Thu Feb 12, 2009 12:19 am
Contact:

Re: question on displaying stats

#7 Post by bozance »

I think I figured out something that works better. I have the two stats positioned on the left and right bottom corners of the screen. I don't know what I'm doing, but it seems to be working out pretty well.

Anyway, LordShiranai--thanks for your fast (and helpful) responses.

Post Reply

Who is online

Users browsing this forum: No registered users