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.
question on displaying stats
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
-
- 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
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:
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.
Just be sure to make sure the variables referenced in the function are initialized before showing the screen.
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)
Code: Select all
label start:
$ player_score = 0
$ player_fear = 3
show screen scoreboard
Don't Blame Me. I Voted for Vermin Supreme.
Re: question on displaying stats
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?
-
- 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
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.
Re: question on displaying stats
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 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.
-
- 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
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.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.
Don't Blame Me. I Voted for Vermin Supreme.
Re: question on displaying stats
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.
Anyway, LordShiranai--thanks for your fast (and helpful) responses.
Who is online
Users browsing this forum: No registered users