Different textbox position depending on the situation

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
Adrian_DVL
Regular
Posts: 114
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Different textbox position depending on the situation

#1 Post by Adrian_DVL » Thu Jan 28, 2021 9:55 am

Hi!

I'd like to change the position of the textbox depending on the situation, and by it I don't mean that I want three or four different positions and neither do I mean I want different characters to have different positions for their textbox, because I'd already know how to do it.

The thing is that my game consists in screens that have sprites of people that appear in different positions, so I want a small textbox to appear next to the sprite, whatever its position is, and changing the position at times for the same character.

I guess I have to mess with window_xpos and window_ypos when defining characters, but I don't see the way to do it without having to define one character per each situation, which would be a pain in the ass.

I've tried to set two variables and to change them each time and to set window_xpos and window_ypos to those variables, but that doesn't work, presumably because characters are objects of a class and I can't change a field like that.

Anyone has an idea? I'd appreciate any help!

User avatar
_ticlock_
Veteran
Posts: 393
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Different textbox position depending on the situation

#2 Post by _ticlock_ » Thu Jan 28, 2021 12:53 pm

Hi, Adrian_DVL,

I think you can use Say with Arguments to specify the position of textbox.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Different textbox position depending on the situation

#3 Post by Alex » Thu Jan 28, 2021 1:05 pm

Adrian_DVL wrote:
Thu Jan 28, 2021 9:55 am
...
Also, you can make custom screen to use instead of standard say screen. But you'll have to mess up with styles a bit... :wink:

Code: Select all

define e = Character("Eileen", who_style='my_say_label', what_style='my_say_dialogue', screen='my_scr')

style my_frame:
    xminimum 400
    yalign 0.0
    
style my_say_label:
    align (0.0, 0.5)
    xminimum 400

style my_say_dialogue:
    align (0.0, 0.0)
    xminimum 400
    
screen my_scr(who, what):
    style_prefix 'my'
    frame:
        align(my_x_align, my_y_align)
        xsize 400
        yminimum 200
        vbox:
            yminimum 200
            align(0.5, 0.05)
            if who:
                frame:
                    background Solid("#c0c0c055")
                    text who size 35 id "who"
            frame:
                background Solid("#c5c5c577")
                text what id "what"


# The game starts here.
label start:
    $ my_x_align, my_y_align = round(renpy.random.random(), 1), round(renpy.random.random(), 1)
    "([my_x_align], [my_y_align])"
    e "Line 1"
    e "Line 2"
    e "Looooooooong Line of text.\nBlah-Blah-Blah\n...\nLooooooooong Line of text.\nBlah-Blah-Blah\n...\nLooooooooong Line of text.\nBlah-Blah-Blah\n...\nLooooooooong Line of text.\nBlah-Blah-Blah\n...\n?"
    jump start
https://www.renpy.org/doc/html/dialogue.html#Character

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: Different textbox position depending on the situation

#4 Post by Remix » Thu Jan 28, 2021 3:28 pm

You could adapt my Speech Bubble dialogue system to your needs...

https://github.com/RenpyRemix/speech-bubbles
Frameworks & Scriptlets:

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Different textbox position depending on the situation

#5 Post by Alex » Thu Jan 28, 2021 4:10 pm

Remix wrote:
Thu Jan 28, 2021 3:28 pm
You could adapt my Speech Bubble dialogue system to your needs...

https://github.com/RenpyRemix/speech-bubbles
Why it's not in a cookbook?...))

User avatar
Adrian_DVL
Regular
Posts: 114
Joined: Fri Mar 15, 2019 8:46 am
Completed: Clockwork Poison
Projects: Melodic Dates, Clockwork Poison: Salvation
Contact:

Re: Different textbox position depending on the situation

#6 Post by Adrian_DVL » Sat Jan 30, 2021 7:33 am

Remix wrote:
Thu Jan 28, 2021 3:28 pm
You could adapt my Speech Bubble dialogue system to your needs...

https://github.com/RenpyRemix/speech-bubbles
Your system made my day, man! Thank you so much!
Also, thanks to _ticlock_ and Alex as always!

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: Different textbox position depending on the situation

#7 Post by Remix » Sun Jan 31, 2021 5:25 am

Alex wrote:
Thu Jan 28, 2021 4:10 pm

Why it's not in a cookbook?...))
On the agenda at some point... time permitting...

Did hope to add several more snippets and then start a cookbook like Tom's one (just a listing of them all in one thread, updated when new ones appear)...
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Google [Bot]