Display stats or information on a screen?
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.
Display stats or information on a screen?
Hi again, maybe this question is stupid but i want to know how to display "stats" or names or whatever information i want in menus or displayables, so how would be the best way to do it?
I see there are other types of user interfaces but they are not explained in the renpy tutorial.
If you can point me out to an example that i can use or a tutorial about this or anything i would be glad.
I see there are other types of user interfaces but they are not explained in the renpy tutorial.
If you can point me out to an example that i can use or a tutorial about this or anything i would be glad.
Re: Display stats or information on a screen?
Here's what I usually do.
Set up the screen.
Make the variables and call the screen in a label
"label" is for displaying text
label _(" Text here ") xpos 20 ypos 30
"[ ]" is for the variables to be displayed. But you need to declare the variables first
label _(" Text here [variable_name]") xpos 20 ypos 20
"textbutton" is for displaying a clickable button with text on it
textbutton _("Text here") action Return() xpos 20 ypos 20
"{color=#f00}" and "{/color}" changes the color of all the text in between them.
label _("{color=#f00} Text here {/color}") xpos 20 ypos 20
There are other things you can do like changing the text size or bold.
label _(" {size=+4} Text here {/size}") xpos 20 ypos 20
label _("{b} Text here {/b}") xpos 20 ypos 20
label _("{size=+4}{color=#f00}{b} Text here {/b}{/color}") xpos 20 ypos 30
~ :)
Set up the screen.
Code: Select all
screen display_stats:
frame:
xalign .1
yalign .1
xsize 320
ysize 240
label _("Name: [MC_name]") xpos 20 ypos 30
label _("{color=#f00}HP [MC_HP]/[MC_maxHP]{/color}") xpos 20 ypos 60
label _("Attack Stat [Char_ATK]") xpos 20 ypos 90
label _("Defense Stat [Char_DEF]") xpos 20 ypos 120
label _("Speed Stat [Char_SPD]") xpos 20 ypos 150
textbutton _("Return") action Return() xpos 20 ypos 180
Code: Select all
label start:
$ MC_name = "Joe"
$ MC_HP = 100
$ MC_maxHP = 100
$ Char_ATK = "8"
$ Char_DEF = "10"
$ Char_SPD = "7"
call screen display_stats
return
label _(" Text here ") xpos 20 ypos 30
"[ ]" is for the variables to be displayed. But you need to declare the variables first
label _(" Text here [variable_name]") xpos 20 ypos 20
"textbutton" is for displaying a clickable button with text on it
textbutton _("Text here") action Return() xpos 20 ypos 20
"{color=#f00}" and "{/color}" changes the color of all the text in between them.
label _("{color=#f00} Text here {/color}") xpos 20 ypos 20
There are other things you can do like changing the text size or bold.
label _(" {size=+4} Text here {/size}") xpos 20 ypos 20
label _("{b} Text here {/b}") xpos 20 ypos 20
label _("{size=+4}{color=#f00}{b} Text here {/b}{/color}") xpos 20 ypos 30
~ :)
If an Owl hoots in a forest, does it make a sound?
Re: Display stats or information on a screen?
I will check the code dude thank you,i suspected it was frames but there are also other types of user interfaces that are kinda in the documentation but since there is no graphical examples you can't tell what they look like and how you could use them.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Display stats or information on a screen?
Note:
Current best practices are to declare variables outside of labels using default (unless they are persistent variables which use define).
So not this:
But this:
Also, make sure you know the difference between calling as screen and showing a screen.
Current best practices are to declare variables outside of labels using default (unless they are persistent variables which use define).
So not this:
Code: Select all
label start:
$ MC_name = "Joe"
$ MC_HP = 100
$ MC_maxHP = 100
$ Char_ATK = "8"
$ Char_DEF = "10"
$ Char_SPD = "7"
call screen display_stats
return
Code: Select all
default MC_name = "Joe"
default MC_HP = 100
default MC_maxHP = 100
default Char_ATK = "8"
default Char_DEF = "10"
default Char_SPD = "7"
label start:
call screen display_stats
return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
Re: Display stats or information on a screen?
Great input, thank you, i use some persistent variables that come from classes so yeah i declared them with define but what you just said is something that was going to bother me sooner or later (how to declare variables outisde labels).trooper6 wrote: ↑Sun Sep 03, 2017 11:52 pm Note:
Current best practices are to declare variables outside of labels using default (unless they are persistent variables which use define).
So not this:
But this:Code: Select all
label start: $ MC_name = "Joe" $ MC_HP = 100 $ MC_maxHP = 100 $ Char_ATK = "8" $ Char_DEF = "10" $ Char_SPD = "7" call screen display_stats return
Also, make sure you know the difference between calling as screen and showing a screen.Code: Select all
default MC_name = "Joe" default MC_HP = 100 default MC_maxHP = 100 default Char_ATK = "8" default Char_DEF = "10" default Char_SPD = "7" label start: call screen display_stats return
About showing and calling, i think show is not persistent and once showed it is "deleted" or something while calling makes it available throught he entire label.
Please correct me if i am wrong.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Display stats or information on a screen?
You shouldn't declare your variables inside labels (you can alter them from inside labels just fine), else it will eventually result in save/load troubles. So always use default (or define)!
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
Re: Display stats or information on a screen?
I edited my post but you were really quick to respond so i will just copy paste what i edited:
About showing and calling, i think show is not persistent and once showed it is "deleted" or something while calling makes it available throught he entire label.
Please correct me if i am wrong.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Display stats or information on a screen?
That is incorrect.
When you show a screen, it opens the screen but it doesn't pause the game. Show screen does not create a new context. So you can show, for example, a screen that has time or some data showing that you want to show for a while and keep going on with your game. (There are ways to make it so that the game doesn't continue while the show screen is up, but that is a story for another time because show doesn't exist context).
When you call a screen, it pauses the game, sends the game to a new context, and waits until it gets information from the screen before it returns to where the game left off. So you can call a screen when you want the player to do something right then and then come back where the game came from.
You are wanting to display stats/information...that sounds like a show rather than a call to me.
When you show a screen, it opens the screen but it doesn't pause the game. Show screen does not create a new context. So you can show, for example, a screen that has time or some data showing that you want to show for a while and keep going on with your game. (There are ways to make it so that the game doesn't continue while the show screen is up, but that is a story for another time because show doesn't exist context).
When you call a screen, it pauses the game, sends the game to a new context, and waits until it gets information from the screen before it returns to where the game left off. So you can call a screen when you want the player to do something right then and then come back where the game came from.
You are wanting to display stats/information...that sounds like a show rather than a call to me.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
Re: Display stats or information on a screen?
Ah, yeah i forgot that with show whatever happens after is going to happen, like "return" and with call it pauses. It will depend how i will use this data because maybe i want some to be always displayed and some only accessible after entering a menu.trooper6 wrote: ↑Mon Sep 04, 2017 2:33 am That is incorrect.
When you show a screen, it opens the screen but it doesn't pause the game. Show screen does not create a new context. So you can show, for example, a screen that has time or some data showing that you want to show for a while and keep going on with your game. (There are ways to make it so that the game doesn't continue while the show screen is up, but that is a story for another time because show doesn't exist context).
When you call a screen, it pauses the game, sends the game to a new context, and waits until it gets information from the screen before it returns to where the game left off. So you can call a screen when you want the player to do something right then and then come back where the game came from.
You are wanting to display stats/information...that sounds like a show rather than a call to me.
Re: Display stats or information on a screen?
There is one way to have information to have information to always be displayed during dialogue. All you would have to do is find the 'Quick Menu screen' and paste all of the code in there. If you use the New GUI Interface, it should look something like this...
Code: Select all
screen quick_menu():
zorder 100
#New stuff here
if quick_menu:
frame:
xalign .1
yalign .1
xsize 320
ysize 240
label _("Name: [MC_name]") xpos 20 ypos 30
label _("{color=#f00}HP [MC_HP]/[MC_maxHP]{/color}") xpos 20 ypos 60
label _("Attack Stat [Char_ATK]") xpos 20 ypos 90
label _("Defense Stat [Char_DEF]") xpos 20 ypos 120
label _("Speed Stat [Char_SPD]") xpos 20 ypos 150
textbutton _("Return") action Return() xpos 20 ypos 180
hbox:
style_prefix "quick"
xalign 0.5
yalign 1.0
textbutton _("Back") action Rollback()
textbutton _("History") action ShowMenu('history')
textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
textbutton _("Auto") action Preference("auto-forward", "toggle")
textbutton _("Save") action ShowMenu('save')
textbutton _("Q.Save") action QuickSave()
textbutton _("Q.Load") action QuickLoad()
textbutton _("Prefs") action ShowMenu('preferences')
## This code ensures that the quick_menu screen is displayed in-game, whenever
## the player has not explicitly hidden the interface.
init python:
config.overlay_screens.append("quick_menu")
default quick_menu = True
style quick_button is default
style quick_button_text is button_text
style quick_button:
properties gui.button_properties("quick_button")
style quick_button_text:
properties gui.button_text_properties("quick_button")
If an Owl hoots in a forest, does it make a sound?
Re: Display stats or information on a screen?
Oh, and you can hide and show the menu whenever you want by doing this.
Add 'define statscreen = True'
and change the variable in the 'label start:' to experiment with it.
and then add "if statscreen == True:" to the quick menu
Note: I'm not the best with using variables, but this seems to work :)
Let know how it goes.
Add 'define statscreen = True'
and change the variable in the 'label start:' to experiment with it.
Code: Select all
#Changed changed variables to define due to trooper6's advise
define MC_name = "Joe"
define MC_HP = 100
define MC_maxHP = 100
define Char_ATK = "8"
define Char_DEF = "10"
define Char_SPD = "7"
define statscreen = True #<----This is new
label start:
"test..."
"hiding the stat screen"
$ statscreen = False #<----This is new
"test..."
"showing the stat screen"
$ statscreen = True #<----This is new
"test... again"
return
Code: Select all
screen quick_menu():
zorder 100
if quick_menu:
if statscreen == True: #<----This is new
frame:
xalign .1
yalign .1
xsize 320
ysize 240
label _("Name: [MC_name]") xpos 20 ypos 30
label _("{color=#f00}HP [MC_HP]/[MC_maxHP]{/color}") xpos 20 ypos 60
label _("Attack Stat [Char_ATK]") xpos 20 ypos 90
label _("Defense Stat [Char_DEF]") xpos 20 ypos 120
label _("Speed Stat [Char_SPD]") xpos 20 ypos 150
textbutton _("Return") action Return() xpos 20 ypos 180
hbox:
style_prefix "quick"
xalign 0.5
yalign 1.0
textbutton _("Back") action Rollback()
textbutton _("History") action ShowMenu('history')
textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
textbutton _("Auto") action Preference("auto-forward", "toggle")
textbutton _("Save") action ShowMenu('save')
textbutton _("Q.Save") action QuickSave()
textbutton _("Q.Load") action QuickLoad()
textbutton _("Prefs") action ShowMenu('preferences')
init python:
config.overlay_screens.append("quick_menu")
default quick_menu = True
style quick_button is default
style quick_button_text is button_text
style quick_button:
properties gui.button_properties("quick_button")
style quick_button_text:
properties gui.button_text_properties("quick_button")
Let know how it goes.
If an Owl hoots in a forest, does it make a sound?
Re: Display stats or information on a screen?
I copied thos code but it didn't work is this a code of your own and i was just supposed to copy the things that you stated and not the entire code?, looks like the default menu of renpy i am confused.JayBlue wrote: ↑Wed Sep 06, 2017 11:07 pm Oh, and you can hide and show the menu whenever you want by doing this.
Add 'define statscreen = True'
and change the variable in the 'label start:' to experiment with it.and then add "if statscreen == True:" to the quick menuCode: Select all
#Changed changed variables to define due to trooper6's advise define MC_name = "Joe" define MC_HP = 100 define MC_maxHP = 100 define Char_ATK = "8" define Char_DEF = "10" define Char_SPD = "7" define statscreen = True #<----This is new label start: "test..." "hiding the stat screen" $ statscreen = False #<----This is new "test..." "showing the stat screen" $ statscreen = True #<----This is new "test... again" return
Note: I'm not the best with using variables, but this seems to workCode: Select all
screen quick_menu(): zorder 100 if quick_menu: if statscreen == True: #<----This is new frame: xalign .1 yalign .1 xsize 320 ysize 240 label _("Name: [MC_name]") xpos 20 ypos 30 label _("{color=#f00}HP [MC_HP]/[MC_maxHP]{/color}") xpos 20 ypos 60 label _("Attack Stat [Char_ATK]") xpos 20 ypos 90 label _("Defense Stat [Char_DEF]") xpos 20 ypos 120 label _("Speed Stat [Char_SPD]") xpos 20 ypos 150 textbutton _("Return") action Return() xpos 20 ypos 180 hbox: style_prefix "quick" xalign 0.5 yalign 1.0 textbutton _("Back") action Rollback() textbutton _("History") action ShowMenu('history') textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True) textbutton _("Auto") action Preference("auto-forward", "toggle") textbutton _("Save") action ShowMenu('save') textbutton _("Q.Save") action QuickSave() textbutton _("Q.Load") action QuickLoad() textbutton _("Prefs") action ShowMenu('preferences') init python: config.overlay_screens.append("quick_menu") default quick_menu = True style quick_button is default style quick_button_text is button_text style quick_button: properties gui.button_properties("quick_button") style quick_button_text: properties gui.button_text_properties("quick_button")
Let know how it goes.
Also i wanted to know how can you customize a stat screen?, like maybe putting an image in the background changing colors, font, type of buttons?
I managed to use the boolean to make it appear or disappear like you suggested, still i have the same question about the code you gave me, i am confused about all those lines.
Another problem arised... when i tested to save my game and then loaded the stats went back to 0 like nothing ever happened i thought saving should save everything?
Re: Display stats or information on a screen?
Only this part is my code:
Code: Select all
if statscreen == True:
frame:
xalign .1
yalign .1
xsize 320
ysize 240
label _("Name: [MC_name]") xpos 20 ypos 30
label _("{color=#f00}HP [MC_HP]/[MC_maxHP]{/color}") xpos 20 ypos 60
label _("Attack Stat [Char_ATK]") xpos 20 ypos 90
label _("Defense Stat [Char_DEF]") xpos 20 ypos 120
label _("Speed Stat [Char_SPD]") xpos 20 ypos 150
textbutton _("Return") action Return() xpos 20 ypos 180
Here's a few links you can look at.
This will teach you how to use Imagebuttons:
viewtopic.php?t=22565
If you want to add images to a screen (There's lots of other good info on this page that might help you.):
https://www.renpy.org/doc/html/screens.html#add
Text tags to change font color:
Code: Select all
"{color=#f00}This is red{/color}"
"{color=#1c03ff}This is blue{/color}"
"{color=#ffeb0c}This is yellow{/color}"
"{color=#e8ff96}This is light green{/color}"
And here's a color wheel to make getting the colors easyer:
https://www.sessions.edu/color-calculator
Here's a link for text tags:
http://renpygen.thelibrarygame.net/Chap ... _Text_Tags
Note: You can use text tags in textbuttons too. Example:
Code: Select all
textbutton _("{color=#1c03ff}Return{/color}") action Return() xpos 20 ypos 180
Here's how it works.
'screen quick_menu()' is different from other screens because it's 'always shown during the in-game dialogue'. So if you put images or text in there, it stands to reason that it would also 'always shown during the in-game dialogue'.
Now if you put that image or text under this ----> 'if statscreen == True:'
That would make image or text 'always shown during the in-game dialogue 'if' the variable called 'statscreen' is 'True''
Now if change the variable 'statscreen' to 'False' while in-game.
That would make image or text 'never shown during the in-game dialogue 'if' the variable called 'statscreen' is 'False''
How are you changing your variables? Here's a visual example of what it should look like exactly. Copy and paste this whole thing into your 'script.rpy' file:
Edit: Maybe try changing the variables to default?
Code: Select all
define e = Character("Eileen")
default MC_name = "Joe"
default MC_HP = 100
default MC_maxHP = 100
default Char_ATK = 3
default Char_DEF = 3
default Char_SPD = 3
default statscreen = True
label start:
"test..."
$ Char_ATK = 42
$ Char_DEF = 25
$ Char_SPD = 33
"test..."
$ statscreen = False
"test..."
$ statscreen = True
"test..."
return
If an Owl hoots in a forest, does it make a sound?
Re: Display stats or information on a screen?
Ok not quoting you because it would be a long ass quote hahaha.
I know how to use imagebuttons and yeah i learned from that link and other help i received here on the forums, what i really wanted to know is if there is a way to make a "cuztom frame", in the example of the frame you gave me the background of the frame is black, but what if i wanted to make it another color or better yet make an image and then use that image as the frame?
About the problem with the variables i solved it thanks to another post that were talking about default vs define, it turns out you need to use default instead of define to declare variables.
And i am using the GUI interface not the old version.
I know how to use imagebuttons and yeah i learned from that link and other help i received here on the forums, what i really wanted to know is if there is a way to make a "cuztom frame", in the example of the frame you gave me the background of the frame is black, but what if i wanted to make it another color or better yet make an image and then use that image as the frame?
About the problem with the variables i solved it thanks to another post that were talking about default vs define, it turns out you need to use default instead of define to declare variables.
And i am using the GUI interface not the old version.
Re: Display stats or information on a screen?
Lol
Glad to hear about the variables. Helps me a bit too.
I don't know how to customize a frame (change the color), though I'm pretty sure there is a way to do it.
If you just want an image instead of a frame, then this is how I do it:
I removed 'frame:' (This will remove the frame.) and replaced it with 'vbox:'.
You don't need the 'xpos' and 'ypos' on the end of the labels because 'vbox:' automatically sorts everything inside of it vertically.
I also put in 'add "images/something_made_in_photoshop.png" xpos 10 ypos 10'. This is to add an image on the screen so it looks like you have a custom frame that way. All you need is an image to put there
You don't even need 'vbox:', you can just remove that and put xpos and ypos on the end of all of the labels and textbuttons:
Let me know if that helps. You can PM me if its easier for you.
Glad to hear about the variables. Helps me a bit too.
I don't know how to customize a frame (change the color), though I'm pretty sure there is a way to do it.
If you just want an image instead of a frame, then this is how I do it:
Code: Select all
if quick_menu:
if statscreen == True:
add "images/something_made_in_photoshop.png" xpos 10 ypos 10
vbox:
xalign .1
yalign .1
xsize 320
ysize 240
label _("Name: [MC_name]")
label _("{color=#f00}HP [MC_HP]/[MC_maxHP]{/color}")
label _("Attack Stat [Char_ATK]")
label _("Defense Stat [Char_DEF]")
label _("Speed Stat [Char_SPD]")
textbutton _("Return") action Return()
You don't need the 'xpos' and 'ypos' on the end of the labels because 'vbox:' automatically sorts everything inside of it vertically.
I also put in 'add "images/something_made_in_photoshop.png" xpos 10 ypos 10'. This is to add an image on the screen so it looks like you have a custom frame that way. All you need is an image to put there
You don't even need 'vbox:', you can just remove that and put xpos and ypos on the end of all of the labels and textbuttons:
Code: Select all
if quick_menu:
if statscreen == True:
add "image/newframe.png" xpos 10 ypos 10
label _("Name: [MC_name]") xpos 20 ypos 10
label _("{color=#f00}HP [MC_HP]/[MC_maxHP]{/color}") xpos 20 ypos 30
label _("Attack Stat [Char_ATK]") xpos 20 ypos 50
label _("Defense Stat [Char_DEF]") xpos 20 ypos 70
label _("Speed Stat [Char_SPD]") xpos 20 ypos 90
textbutton _("Return") action Return() xpos 20 ypos 110
If an Owl hoots in a forest, does it make a sound?
Who is online
Users browsing this forum: DewyNebula