Page 1 of 1
show variable in right corner [SOLVED]
Posted: Thu Aug 11, 2016 10:31 am
by de_nederlander
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.
Re: show variable in right corner
Posted: Thu Aug 11, 2016 10:55 am
by Iylae
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
Posted: Thu Aug 11, 2016 10:59 am
by de_nederlander
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"
it works, but is there a way to adjust the size and the position?
Re: show variable in right corner
Posted: Thu Aug 11, 2016 11:03 am
by Iylae
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
Re: show variable in right corner
Posted: Thu Aug 11, 2016 11:26 am
by de_nederlander
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
Posted: Thu Aug 11, 2016 11:29 am
by Iylae
de_nederlander wrote:do I have to hide and show it again
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.
Re: show variable in right corner
Posted: Thu Aug 11, 2016 11:30 am
by de_nederlander
Iylae wrote:de_nederlander wrote:do I have to hide and show it again
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.
okay thanks a lot.
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
Posted: Thu Aug 11, 2016 11:36 am
by Iylae
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.
Re: show variable in right corner
Posted: Thu Aug 11, 2016 12:34 pm
by Alex
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?
But what's the code to increase the money amount?
Re: show variable in right corner
Posted: Thu Aug 11, 2016 1:45 pm
by de_nederlander
Alex wrote: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?
But what's the code to increase the money amount?
I use $ money += earn
Re: show variable in right corner [SOLVED]
Posted: Thu Aug 11, 2016 1:59 pm
by Alex
If you do it this way, the value of money variable should update in screen.
Re: show variable in right corner [SOLVED]
Posted: Thu Aug 11, 2016 2:05 pm
by de_nederlander
Alex wrote:If you do it this way, the value of money variable should update in screen.
it doesn't
Re: show variable in right corner [SOLVED]
Posted: Thu Aug 11, 2016 2:17 pm
by Alex
This code works
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
"?"
So check if "earn" is not zero.
Re: show variable in right corner [SOLVED]
Posted: Thu Aug 11, 2016 2:25 pm
by de_nederlander
Alex wrote:This code works
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
"?"
So check if "earn" is not zero.
it works now, I used str(money) instead of [money], thanks, my code is a lot smaller now