Hi, I'm still getting used to ren.py and I'm trying to figure out how to show stats values(Strength, Charisma, Magic, etc) as part of UI. Just in a few boxes lined up against the top right of the screen. Is there something in the cookbook I can use as a template?
Thanks!
How to display Stat values as part of the UI?
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.
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.
-
- Newbie
- Posts: 24
- Joined: Sun Apr 26, 2015 9:29 pm
- Contact:
Re: How to display Stat values as part of the UI?
Hi, it depends on if you are going to use classes. I can share you my code from my game I'm currently making, but it might not make sense to you xD. I suggest you read the guide on classes and screen language and go from there! I'll share you my code as a reference. There is probably more ways to do this, but here is mine:
Screen language:
The Code in script python:
You could also take a look at Leon's inventory screen renpy template.
Good luck~
Screen language:
Code: Select all
# Status Menu/Screen used for Characters!
screen roystatus:
frame:
xpos 20
ypos 550
has vbox
text "{b}{color=#000033}Nagisuna:{/b}{/color}"
text "{color=#000000}Personality: [Nagisuna.personality]{/color}"
text "{color=#000000}Mood Points: [Nagisuna.mood]{/color}"
textbutton "Return" action Return()
init -2:
style roystatus:
size 18
label roystatus_label:
call screen roystatus_screen
return
The Code in script python:
Code: Select all
class Player(renpy.store.object):
def __init__(self, name, mood=0, personality=None):
self.name=name
self.mood = mood
self.personality = personality
self.startmood = 0
def moodpoints(self, thechoice):
if(thechoice == 'good'):
self.mood += 1
elif(thechoice == 'bad'):
self.mood -= 2
elif(thehoice == 'none'):
self.mood = self.mood
def showpoints(self):
print(str(self.mood) + " points.")
def status_overlay(self):
mood = self.mood
name = self.name
if statusshow:
ui.window(xpos=100, xanchor=100, ypos=100, yanchor=100, background="statoverlay.png", yfill=True, xfill=True)
ui.vbox(xpos=100, xanchor=100, ypos=100, yanchor=100, clipping=False, spacing=12)
ui.text(name + ": " + "%d" % mood + " mood points", size=30, color="#091a2c")
ui.close()
player = Player("Person", 100, 100)
Good luck~
If people ignore others with a lack of understanding, then they are close-minded.
-
- Newbie
- Posts: 24
- Joined: Sun Apr 26, 2015 9:29 pm
- Contact:
Re: How to display Stat values as part of the UI?
That was much easier than I thought! I'll also take a look at Leon's inventory template, thank you!
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]