"Speech bubbles" with left and right variation? [SOLVED]

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
TAEKO
Newbie
Posts: 21
Joined: Mon Jul 23, 2018 3:24 am
Contact:

"Speech bubbles" with left and right variation? [SOLVED]

#1 Post by TAEKO » Tue Sep 04, 2018 6:17 am

What I am trying to is this:
When Character A is speaking and is on the left portion of the screen, the speech bubble faces said character. But when Character B arrives, his namebox appears without Character A's namebox disappearing and the speech bubble turns to face him instead along with the changing of the corresponding image of the speech bubble.
Image
Image

I was wondering if there is a way how to let the other namebox stay while the other character is speaking?

Here's what I've done so far, I defined two characters, one for the left and one for the right, both using the same image.

Code: Select all

define yuki = Character("Mochizuki, Yuki", callback=speaker("Mochizuki, Yuki"), who_color="#1E3D54", image="yuki", namebox_background = "gui/box/namebox.png", window_background="gui/box/blue_L.png")

define yuki_flip = Character("Mochizuki, Yuki", callback=speaker("Mochizuki, Yuki"), who_color="#1E3D54", image="yuki flip", namebox_background = "gui/box/namebox.png", window_background="gui/box/blue_R.png")

Code: Select all

image yuki flip shy= im.Flip("images/sprites/yuki/yuki_shy.png", horizontal=True, xalign=1.0)
image yuki shy= Image("images/sprites/yuki/yuki_shy.png", horizontal=True, xalign=0.0)
Here are the styles of the left and right nameboxes

Code: Select all

style namebox: #left
    xpos 10
    xalign 0.0
    xsize gui.namebox_width
    ypos gui.name_ypos
    ysize gui.namebox_height
    padding gui.namebox_borders.padding

style namebox2: #right
    xpos 964
    xsize gui.namebox_width
    ypos gui.name_ypos
    ysize gui.namebox_height
    padding gui.namebox_borders.padding
And finally the namebox transition...
This is where I had problems aside from retaining the appearances of the two nameboxes.
Is there a way to assign a value to whenever the flipped character is called?

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"
        if who is not None:
            window:
                if flipped == True: #Is it possible to assign a value like this whenever the flipped speaker shows up?
                    if nameboxtrans == "In_trans":
                        at name_ease
                    else:
                        pass
                    id "namebox"
                    style "namebox"
                    text who id "who"
                else:
                    if nameboxtrans == "In_trans":
                        at name_ease_flipped
                    else:
                        pass
                    id "namebox"
                    style "namebox2"
                    text who id "who"
Last edited by TAEKO on Thu Sep 06, 2018 9:33 pm, edited 2 times in total.
Don't read me...
Seriously don't.
Just kidding. I'm just an awkward potato who doesn't know what to say in my signature...

User avatar
Andredron
Veteran
Posts: 396
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: "Speech bubbles" with left and right variation?

#2 Post by Andredron » Tue Sep 04, 2018 6:30 am

I know, I'm writing terribly in English.

I'm writing a Renpy textbook (in Russian). https://yadi.sk/d/ZX_DonP63USRru Update 22.06.18

Honest Critique

User avatar
Donmai
Eileen-Class Veteran
Posts: 1867
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: "Speech bubbles" with left and right variation?

#3 Post by Donmai » Tue Sep 04, 2018 2:45 pm

Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
TAEKO
Newbie
Posts: 21
Joined: Mon Jul 23, 2018 3:24 am
Contact:

Re: "Speech bubbles" with left and right variation?

#4 Post by TAEKO » Tue Sep 04, 2018 4:07 pm

Donmai wrote:
Tue Sep 04, 2018 2:45 pm
You can also look here:
https://www.patreon.com/posts/automatic-speech-17867321
Hi! Thanks for both of your answers. I find both of those links really helpful, but right now my main problem is how to show the second namebox without the first one disappearing. I've just fixed the transitions and the automatic facing of the chat bubbles a while after I originally posted this, (which I may or may not have written in the noobiest way possible btw, but hey at least it works), and pretty much that is my only problem...

I tried doing the first method, but I just can't seem to tie it with the custom nameboxes I've prepared. It's like a fixed dialogue box, but at the moment I'm still going to work on it until I figure it out (but if I don't, I think what it can do now is pretty much cool anyway so it might be already fine without the extra feature), anyway thanks again for trying to help!

Should I put a [Solved] in the title now or...? Well since it's not really fully 'solved' I guess Partially Solved would be more appropriate huh
Don't read me...
Seriously don't.
Just kidding. I'm just an awkward potato who doesn't know what to say in my signature...

User avatar
MaydohMaydoh
Regular
Posts: 101
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: "Speech bubbles" with left and right variation?

#5 Post by MaydohMaydoh » Tue Sep 04, 2018 4:31 pm

You could try this, whether it works or not or if it's the right way to do it or whatever, I don't know.
Using two variables, one for left and one for right

Code: Select all

default left_speaker = ""
default right_speaker = ""
Put the name of each person into their respective variables

Code: Select all

label start:
    $ left_speaker = "Some dude"
    $ right_speaker = "A cat"
    left_speaker "Hey look, it's a cat."
    right_speaker "Meow"
Then in the say screen, just check if the variable is empty or not and show the appropriate namebox.

Code: Select all

screen say(who, what):
    if left_speaker: ## if right_speaker is not empty string, show namebox left
        window id 'namebox':
            style 'namebox'
            text "[left_speaker]"
    
    if right_speaker: ## if right_speaker is not empty string, show namebox right
        window id 'namebox':
            style 'namebox2'
            text "[right_speaker]"
           
    ## plus whatever else you want
Then when you want to hide the namebox, just give the variable an empty string or False or None or whatever or give it a new name to show something different.

Code: Select all

$ left_speaker = ""
$ right_speaker = "A dog"
right_speaker "I was a dog all along."

User avatar
TAEKO
Newbie
Posts: 21
Joined: Mon Jul 23, 2018 3:24 am
Contact:

Re: "Speech bubbles" with left and right variation?

#6 Post by TAEKO » Wed Sep 05, 2018 8:13 am

MaydohMaydoh wrote:
Tue Sep 04, 2018 4:31 pm
You could try this, whether it works or not or if it's the right way to do it or whatever, I don't know.
Using two variables, one for left and one for right

Code: Select all

default left_speaker = ""
default right_speaker = ""
Put the name of each person into their respective variables

Code: Select all

label start:
    $ left_speaker = "Some dude"
    $ right_speaker = "A cat"
    left_speaker "Hey look, it's a cat."
    right_speaker "Meow"
Then in the say screen, just check if the variable is empty or not and show the appropriate namebox.

Code: Select all

screen say(who, what):
    if left_speaker: ## if right_speaker is not empty string, show namebox left
        window id 'namebox':
            style 'namebox'
            text "[left_speaker]"
    
    if right_speaker: ## if right_speaker is not empty string, show namebox right
        window id 'namebox':
            style 'namebox2'
            text "[right_speaker]"
           
    ## plus whatever else you want
Then when you want to hide the namebox, just give the variable an empty string or False or None or whatever or give it a new name to show something different.

Code: Select all

$ left_speaker = ""
$ right_speaker = "A dog"
right_speaker "I was a dog all along."
Hey I tried your way and it works btw! But a new problem arised for me...
The two nameboxes now appear, but the second one is copied to the first one as if the same person is on both sides.
Also, when I implemented this, the styles I made especially for the textboxes' text seems to not be read...?
Here is a video of the effect:
[youtube]https://youtu.be/dIsELc2k0Iw[/youtube]

Any idea how to fix this?
I'd appreciate it if anyone could tell me what I did wrong

Here's what I did:
if who is not None:

Code: Select all

            if left_speaker is not None:
                window:
                    if nameboxtrans == "In_trans":
                        at name_ease
                    else:
                        pass
                    id "namebox"
                    text who id left_speaker
                    style "namebox"

            if right_speaker is not None:
                window:
                    if nameboxtrans == "In_trans":
                        at name_ease_flipped
                    else:
                        pass
                    id "namebox"
                    text who id right_speaker
                    style "namebox2"

Code: Select all

label start:
    show yuki L shy
    $ left_speaker = yuki
    yuki "... boop?"
    show momo R neutral
    $ right_speaker = momo
    momo "Boop bap?"

Code: Select all

    def yuki(what, **kwargs):
        global right_speaker, left_speaker

        if left_speaker is yuki:
            yuki_L(what, **kwargs)
        elif right_speaker is yuki:
            yuki_R(what,**kwargs)
EDIT:
Decided to work with just only one namebox in the end. I mean it looks pretty much okay at this point anyway
Marked question as solved, thanks everyone!
Don't read me...
Seriously don't.
Just kidding. I'm just an awkward potato who doesn't know what to say in my signature...

Post Reply

Who is online

Users browsing this forum: foleso, Google [Bot]