show variable in right corner [SOLVED]
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: 21
- Joined: Thu Aug 04, 2016 8:26 am
- Contact:
show variable in right corner [SOLVED]
Maybe I'm asking quite some questions lately but,
how do I show a variable in the right corner of the screen, I would like the player to see how much coins he has, and how much points.
I've tried looking for how ui.text works but I just can't see how to style them and place them.
thanks for your help.
how do I show a variable in the right corner of the screen, I would like the player to see how much coins he has, and how much points.
I've tried looking for how ui.text works but I just can't see how to style them and place them.
thanks for your help.
Last edited by de_nederlander on Thu Aug 11, 2016 11:32 am, edited 1 time in total.
Re: show variable in right corner
A simple example:
Code: Select all
screen show_money():
frame:
xalign 1.0
text str(money)
label start:
default money = 10
show screen show_money
"test"
If we are what we repeatedly do, then good coding is not an act, but a habit
-
- Newbie
- Posts: 21
- Joined: Thu Aug 04, 2016 8:26 am
- Contact:
Re: show variable in right corner
it works, but is there a way to adjust the size and the position?Iylae wrote:A simple example:
Code: Select all
screen show_money(): frame: xalign 1.0 text str(money) label start: default money = 10 show screen show_money "test"
Re: show variable in right corner
see https://www.renpy.org/doc/html/screens.html#text and follow the links for the properties you can apply to text.
also see https://www.renpy.org/doc/html/screens.html#frame for the links for the properties you can apply to the frame
also see https://www.renpy.org/doc/html/screens.html#frame for the links for the properties you can apply to the frame
If we are what we repeatedly do, then good coding is not an act, but a habit
-
- Newbie
- Posts: 21
- Joined: Thu Aug 04, 2016 8:26 am
- Contact:
Re: show variable in right corner
everything works with this, but it doesn't seem to update once it more money is added.Iylae wrote:see https://www.renpy.org/doc/html/screens.html#text and follow the links for the properties you can apply to text.
also see https://www.renpy.org/doc/html/screens.html#frame for the links for the properties you can apply to the frame
do I have to hide and show it again, or is there another way?
Re: show variable in right corner
That's the only way I know. I would recommend (if you know how) building a function that both updates the money and refreshes (re-shows) the screen. That way you won't ever forget to update the screen.de_nederlander wrote:do I have to hide and show it again
If we are what we repeatedly do, then good coding is not an act, but a habit
-
- Newbie
- Posts: 21
- Joined: Thu Aug 04, 2016 8:26 am
- Contact:
Re: show variable in right corner
okay thanks a lot.Iylae wrote:That's the only way I know. I would recommend (if you know how) building a function that both updates the money and refreshes (re-shows) the screen. That way you won't ever forget to update the screen.de_nederlander wrote:do I have to hide and show it again
I've seen you answering quite some questions lately, so I hope you are able to help a lot more people.
Re: show variable in right corner
As a Karate Instructor in my spare time, I've come to appreciate that a viable way to improve at something is to teach it to others.
There's a quote I'm fond of though I forget the source: "docendo disco, scribendo cogito" meaning "I learn by teaching, I think by writing".
Sadly my knowledge is moderate and narrow at best, so I can't help with most people's problems with Ren'Py as a whole, but basic programming isn't too much of a hassle for me.
There's a quote I'm fond of though I forget the source: "docendo disco, scribendo cogito" meaning "I learn by teaching, I think by writing".
Sadly my knowledge is moderate and narrow at best, so I can't help with most people's problems with Ren'Py as a whole, but basic programming isn't too much of a hassle for me.
If we are what we repeatedly do, then good coding is not an act, but a habit
Re: show variable in right corner
But what's the code to increase the money amount?de_nederlander wrote:everything works with this, but it doesn't seem to update once it more money is added.
do I have to hide and show it again, or is there another way?
-
- Newbie
- Posts: 21
- Joined: Thu Aug 04, 2016 8:26 am
- Contact:
Re: show variable in right corner
I use $ money += earnAlex wrote:But what's the code to increase the money amount?de_nederlander wrote:everything works with this, but it doesn't seem to update once it more money is added.
do I have to hide and show it again, or is there another way?
Re: show variable in right corner [SOLVED]
If you do it this way, the value of money variable should update in screen.
-
- Newbie
- Posts: 21
- Joined: Thu Aug 04, 2016 8:26 am
- Contact:
Re: show variable in right corner [SOLVED]
it doesn'tAlex wrote:If you do it this way, the value of money variable should update in screen.
Re: show variable in right corner [SOLVED]
This code works
So check if "earn" is not zero.
Code: Select all
screen my_scr():
text "money: [money]" size 35 color "#c00" align (0.5, 0.05)
default money = 100
label start:
"..."
show screen my_scr
"."
$ money += 10
"?"
-
- Newbie
- Posts: 21
- Joined: Thu Aug 04, 2016 8:26 am
- Contact:
Re: show variable in right corner [SOLVED]
it works now, I used str(money) instead of [money], thanks, my code is a lot smaller nowAlex wrote:This code worksSo check if "earn" is not zero.Code: Select all
screen my_scr(): text "money: [money]" size 35 color "#c00" align (0.5, 0.05) default money = 100 label start: "..." show screen my_scr "." $ money += 10 "?"
Who is online
Users browsing this forum: Semrush [Bot]