Floating Text?

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.
Message
Author
jackalope044
Newbie
Posts: 16
Joined: Fri Sep 23, 2011 8:07 pm
Contact:

Floating Text?

#1 Post by jackalope044 »

Hey there, guys. I wanted to add floating text (I.E. Outside of the bottom text box, at various points on the screen) to my game, but I currently have no clue how I'd do something like this. I managed to get text that was completely centered on the screen, but I want to figure out how to put it at all places on the screen.

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Floating Text?

#2 Post by Camille »

You'd have to make a screen with text on it.

jackalope044
Newbie
Posts: 16
Joined: Fri Sep 23, 2011 8:07 pm
Contact:

Re: Floating Text?

#3 Post by jackalope044 »

Well, I tried something here:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40
    xpos 0.3 ypos 0.3
And got this:

Code: Select all

File "game/script.rpy", line 20: Expected a screen language statement.
    xpos 0.3 ypos 0.3
        ^

Another
Regular
Posts: 82
Joined: Sun Apr 18, 2010 8:57 am
Contact:

Re: Floating Text?

#4 Post by Another »

There are two ways to do this.

Either you write everything on the same line:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3
or you add a colon and indent:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!":
        size 40
        xpos 0.3 ypos 0.3

jackalope044
Newbie
Posts: 16
Joined: Fri Sep 23, 2011 8:07 pm
Contact:

Re: Floating Text?

#5 Post by jackalope044 »

Another wrote:There are two ways to do this.

Either you write everything on the same line:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3
or you add a colon and indent:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!":
        size 40
        xpos 0.3 ypos 0.3
Wow, that was simple enough. I feel stupid now.

Thank you very much either way, though.

As for another question; Is there a way to give a border to the text? Like, white text with a black border? Just so that it doesn't blend in with my background and is actually readable?

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Floating Text?

#6 Post by Camille »

That would be outline, and yes you can. Just add text style properties next to (or under, depends on which system you're using) your xpos and ypos stuff.

jackalope044
Newbie
Posts: 16
Joined: Fri Sep 23, 2011 8:07 pm
Contact:

Re: Floating Text?

#7 Post by jackalope044 »

Camille wrote:That would be outline, and yes you can. Just add text style properties next to (or under, depends on which system you're using) your xpos and ypos stuff.
The code I'm using:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3 outlines (20, color("#000000"), 0, 0)
The error I'm getting:

Code: Select all

 File "game/script.rpy", line 352, in script
        call screen tennisclub
  File "renpy-6.12.0-mainline/common/00statements.rpy", line 532, in python
  File "game/script.rpy", line 29, in python
        text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3 outlines (20, color("#000000"), 0, 0)
TypeError: object of type 'int' has no len()
Any clue? Also, thanks for all the help.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Floating Text?

#8 Post by PyTom »

Outlines takes a list. Write it as:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3 outlines [ (20, "#000", 0, 0) ]
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

jackalope044
Newbie
Posts: 16
Joined: Fri Sep 23, 2011 8:07 pm
Contact:

Re: Floating Text?

#9 Post by jackalope044 »

PyTom wrote:Outlines takes a list. Write it as:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3 outlines [ (20, "#000", 0, 0) ]
Thanks!

It worked to display it, but the only problem is is that it doesn't allow the user to go past after the screen is displayed.

Another
Regular
Posts: 82
Joined: Sun Apr 18, 2010 8:57 am
Contact:

Re: Floating Text?

#10 Post by Another »

The answer depends on the way you called your screen.

With show screen, you'll usually use hide screen:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3 outlines [(20, "#000", 0, 0)]

label start:
    me "What should I do?"
    show screen tennisclub
    ""
    hide screen tennisclub
    me "All right..."
But since show screen wouldn't prevent the player from continuing, I presume you used call screen. Here, things get a bit more complicated. Indeed, the screen is waiting for an interaction. You should thus add a button or a timer to your screen. Example:

Code: Select all

screen tennisclub:
    vbox xpos 0.3 ypos 0.3:
        text "Please join the tennis club!" size 40 outlines [(20, "#000", 0, 0)]
        textbutton "Ok" action Jump("continue")

label start:
    me "What should I do?"
    call screen tennisclub

label continue:
    me "All right..."

jackalope044
Newbie
Posts: 16
Joined: Fri Sep 23, 2011 8:07 pm
Contact:

Re: Floating Text?

#11 Post by jackalope044 »

Another wrote:The answer depends on the way you called your screen.

With show screen, you'll usually use hide screen:

Code: Select all

screen tennisclub:
    text "Please join the tennis club!" size 40 xpos 0.3 ypos 0.3 outlines [(20, "#000", 0, 0)]

label start:
    me "What should I do?"
    show screen tennisclub
    ""
    hide screen tennisclub
    me "All right..."
But since show screen wouldn't prevent the player from continuing, I presume you used call screen. Here, things get a bit more complicated. Indeed, the screen is waiting for an interaction. You should thus add a button or a timer to your screen. Example:

Code: Select all

screen tennisclub:
    vbox xpos 0.3 ypos 0.3:
        text "Please join the tennis club!" size 40 outlines [(20, "#000", 0, 0)]
        textbutton "Ok" action Jump("continue")

label start:
    me "What should I do?"
    call screen tennisclub

label continue:
    me "All right..."
Ahh, yes, using "Show Screen" as opposed to "Call Screen" made it work perfectly fine.

Thanks very much!

Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Floating Text?

#12 Post by Soraminako »

Sorry to jump into the conversation, but is there a way to use the outline around the text when using text in an ui?

I'm using the love measuring bars but they're extremely hard to see against some of my backgrounds. :?

Code: Select all

        ui.text("{font=font02.ttf}Bob's love for you:{/font} ")
        ui.bar(Bob_max, Bob_points)
        ui.text("Larry's love for you: ")
        ui.bar(Larry_max, Larry_points)
        ui.close() # for the vbox
I found in another thread how to replace the bar with images, but I'm stupidly getting stuck on the text with the names being invisible against many of my backgrounds. :?

So I'll have to either replace that by an image (aaargghh!! yet more images to make!!) or figure out how to make the outline code work within the ui thing. :?
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Floating Text?

#13 Post by PyTom »

Yes. You can do:

Code: Select all

init python:
    style.default.outlines = [ (1, "#000", 0, 0) ]
And then remove it from other places.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: Floating Text?

#14 Post by Soraminako »

Thank you PyTom!! :D

And not for another epic noob moment, but... how do you remove that style from the other places? ^^;;;
Last edited by Soraminako on Tue Sep 27, 2011 3:46 pm, edited 1 time in total.
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Floating Text?

#15 Post by PyTom »

Which places do you want it in, and which not?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users