Displaying text at a particular x y coordinate

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
Dookiesh0ez
Newbie
Posts: 8
Joined: Wed May 24, 2017 3:53 pm
Projects: Sexventure Time
Contact:

Displaying text at a particular x y coordinate

#1 Post by Dookiesh0ez »

I'm trying to use show screen to show text at a certain coordinate. I saw documentation that it should look something like this

Code: Select all

screen money:
    text ("%d" % money)
    xpos 10.0
    ypos 10.0
But that isn't working, the text always displays at the upper left corner, 0, 0. And frustratingly I now can't find the page in the documentation or wiki where I originally found this and I need to get this done to move on.

So what is the correct way to set the coordinates of this text?

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Displaying text at a particular x y coordinate

#2 Post by xavimat »

Two problems and a two suggestions:

1. There is an indentation problem in your code. Here there are two options.
2. An integer number means "pixels" a float number means "% in the screen". This is somewhat tricky, see the tutorial game to learn about it.
3. Don't need the % python code, the simple [variable] should do.
4. Don't forget the parenthesis in the screen definition (it's improved SL).

Code: Select all

screen money():
    text "[money]" xpos 10 ypos 10
    text "[money]":
        xpos 10
        ypos 10
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Dookiesh0ez
Newbie
Posts: 8
Joined: Wed May 24, 2017 3:53 pm
Projects: Sexventure Time
Contact:

Re: Displaying text at a particular x y coordinate

#3 Post by Dookiesh0ez »

xavimat wrote:Two problems and a two suggestions:

1. There is an indentation problem in your code. Here there are two options.
2. An integer number means "pixels" a float number means "% in the screen". This is somewhat tricky, see the tutorial game to learn about it.
3. Don't need the % python code, the simple [variable] should do.
4. Don't forget the parenthesis in the screen definition (it's improved SL).

Code: Select all

screen money():
    text "[money]" xpos 10 ypos 10
    text "[money]":
        xpos 10
        ypos 10
Thanks for the quick reply. Good to know the float / int difference. And I never would have known the indentation was wrong because I wasn't getting any exceptions, strange.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Displaying text at a particular x y coordinate

#4 Post by xavimat »

Dookiesh0ez wrote:And I never would have known the indentation was wrong because I wasn't getting any exceptions, strange.
I'll report it as a possible bug: Should xpos and ypos outside a screen element cause an exception?
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Dookiesh0ez
Newbie
Posts: 8
Joined: Wed May 24, 2017 3:53 pm
Projects: Sexventure Time
Contact:

Re: Displaying text at a particular x y coordinate

#5 Post by Dookiesh0ez »

I don't know, I'm not that familiar with renpy, but every other indentation error i've had so far has caused one. I don't really see how xpos and ypos outside of the correct syntax could be useful though.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Displaying text at a particular x y coordinate

#6 Post by xavimat »

renpytom has solved it. It was a bug. In the next release it should throw an exception (IIUIC).
Thanks.

https://github.com/renpy/renpy/issues/1188
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], LuckyT, tim640