Display text with specific position and style

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
Newnewbie
Newbie
Posts: 23
Joined: Sun Dec 08, 2019 4:06 am
Contact:

Display text with specific position and style

#1 Post by Newnewbie »

Hi guys!

I'm searched for hours for an answer and didn't find it. You have to know that I am very newbie with Ren py and also, english is not my native language. I'm sorry if I'm not very understandable x)

I would display the name of the player with a specific position and specific style (the name have been chosen by the player with the input function).

So, here's my code :

Code: Select all

show text "[name_of_the_player]" at center
My problem is that I cannot choose a specific position, change the color, size and the font of the text...

I already tried like 48154 things but it never worked T_T Help would be very appreciated!

User avatar
deltadidirac
Regular
Posts: 123
Joined: Fri Nov 30, 2018 5:00 am
Projects: Artworks and Comics
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: Display text with specific position and style

#2 Post by deltadidirac »

Newnewbie wrote: Sun Dec 08, 2019 4:30 am Hi guys!

I'm searched for hours for an answer and didn't find it. You have to know that I am very newbie with Ren py and also, english is not my native language. I'm sorry if I'm not very understandable x)

I would display the name of the player with a specific position and specific style (the name have been chosen by the player with the input function).

So, here's my code :

Code: Select all

show text "[name_of_the_player]" at center
My problem is that I cannot choose a specific position, change the color, size and the font of the text...

I already tried like 48154 things but it never worked T_T Help would be very appreciated!
If your problem is only to define the name of the character that is speaking....
so, you must see the file "GUI" and look all the definition and setting about the "name.box"

on how to chenage the color of the "name" for each character and/or his dialogue text , you must define this (generally at the begin in the script file)
as is:

Code: Select all

define m = Character ("{b}Myriam{/b}", color="9dc209", what_color='#a1ff43', what_xpos=90, what_textalign=0)
see you

User avatar
Newnewbie
Newbie
Posts: 23
Joined: Sun Dec 08, 2019 4:06 am
Contact:

Re: Display text with specific position and style

#3 Post by Newnewbie »

Hello Deltadidirac,

Thank you so much for your answer. But my issue is elsewhere. I'm so sorry for my bad explaining...

I have no problem for positionning and stylising my characters names in the dialogues. My issue is when I would want to display the name elsewhere like i did in this picture :

https://www.noelshack.com/2019-49-7-157 ... xample.png

Thank you

User avatar
deltadidirac
Regular
Posts: 123
Joined: Fri Nov 30, 2018 5:00 am
Projects: Artworks and Comics
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: Display text with specific position and style

#4 Post by deltadidirac »

you must use a displayable...

there is also in the turorial.

simply you must build a screen that contain a text, and after in your lable when you have need, you call it with "show/hide screen" commands

done
(give a fast look to the tutorial of renpy in the displayable section)

User avatar
Newnewbie
Newbie
Posts: 23
Joined: Sun Dec 08, 2019 4:06 am
Contact:

Re: Display text with specific position and style

#5 Post by Newnewbie »

Going to check it, thank you!

User avatar
Newnewbie
Newbie
Posts: 23
Joined: Sun Dec 08, 2019 4:06 am
Contact:

Re: Display text with specific position and style

#6 Post by Newnewbie »

I have tried this :

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

# Le jeu commence ici
label start:

screen text_example():
  frame:
    xalign 0.5 ypos 50
    text "Text tags {color=#c8ffc8}work{/color} in screens.":
      size 30

e "This is a test"
 
return
Its comes from directly from the tutorial, but it does'nt display anyting (I mean eccept the dialogue test) :/ Does someone know why please?

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Display text with specific position and style

#7 Post by IrinaLazareva »

Newnewbie wrote: Sun Dec 08, 2019 8:40 am

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

# Le jeu commence ici
label start:

screen text_example():
  frame:
    xalign 0.5 ypos 50
    text "Text tags {color=#c8ffc8}work{/color} in screens.":
      size 30

e "This is a test"
 
return
The screen is a function. It is written outside the label start (like all variables).

But it is not enough to write it down. Then it should be called. To do this, use the commands show and call

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

screen text_example():
  frame:
    xalign 0.5 ypos 50
    text "Text tags {color=#c8ffc8}work{/color} in screens.":
      size 30
      
      
# Le jeu commence ici
label start:
    show screen text_example
    e "This is a test"
 
    return
More detailes: https://renpy.org/doc/html/screens.html ... statements

User avatar
Newnewbie
Newbie
Posts: 23
Joined: Sun Dec 08, 2019 4:06 am
Contact:

Re: Display text with specific position and style

#8 Post by Newnewbie »

Thank you very much... You helped me a lot

User avatar
Newnewbie
Newbie
Posts: 23
Joined: Sun Dec 08, 2019 4:06 am
Contact:

Re: Display text with specific position and style

#9 Post by Newnewbie »

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

screen text_example():
  frame:
    xalign 0.5 ypos 50
    text "Text tags {color=#c8ffc8}work{/color} in screens.":
      size 30
      
      
# Le jeu commence ici
label start:
    show screen text_example
    e "This is a test"
 
    return
    
Ok, I'm stucked again..

The code works perfectly, but there is a black box background behind my text and I cannot find how to change the font style. Do you know how could I remove the black background and change the font style of the text ?

I'm so sorry for all these newbie questions...

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Display text with specific position and style

#10 Post by IrinaLazareva »

Newnewbie wrote: Sun Dec 08, 2019 10:03 am The code works perfectly, but there is a black box background behind my text and I cannot find how to change the font style. Do you know how could I remove the black background and change the font style of the text ?
"black box" refers to an frame element. If it is not needed, it can be removed. And style settings, positions can be applied directly to the text.

Code: Select all

screen text_example():
    text "Text tags {color=#c8ffc8}work{/color} in screens." xalign 0.5 ypos 50 size 30
Read the documentation first https://renpy.org/doc/html/screens.html#text
The text statement displays text. It takes a single parameter, the text to display. It also takes the following groups of properties:

Common Properties
Position Style Properties
Text Style Properties <<<<< about font style of the text


4 example

Code: Select all

screen text_example():
    text "Text tags {color=#c8ffc8}work{/color} in screens." xalign 0.5 ypos 50 size 30 italic True color "#f00" font 'DejaVuSans.ttf' 
P.S. If you use your own fonts, the font files should be placed in the game folder of project

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Display text with specific position and style

#11 Post by Remix »

You could also just use the Text() displayable directly

Code: Select all

    show expression Text("Some Text", size=42, color='#688') at truecenter
Alternatively, you can define the style in a ParameterizedText image and reference that

Code: Select all

image info_text = ParameterizedText(size=42, color='#A46C')

label start:

    show info_text "Parameterized Text": # show info_text will use that image with the passed string
        pos (400,100)
Last edited by Remix on Sun Dec 08, 2019 1:02 pm, edited 1 time in total.
Frameworks & Scriptlets:

User avatar
Newnewbie
Newbie
Posts: 23
Joined: Sun Dec 08, 2019 4:06 am
Contact:

Re: Display text with specific position and style

#12 Post by Newnewbie »

Thank so much for your help guys T_T

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], Yahoo [Bot]