Sometimes prevent dialogue transitions in say screen?

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
lindsay-jb
Regular
Posts: 61
Joined: Tue Aug 25, 2020 1:05 am
Contact:

Sometimes prevent dialogue transitions in say screen?

#1 Post by lindsay-jb » Tue Apr 05, 2022 1:44 pm

Hello! I have done a lot of heightened customization with my say screen to created automatically resizing textboxes on the right side, middle, and left side of the screen. The playable character box shows on the left side, the narration in the middle, and NPCs on the right side. Now, I am wanting to add transitions. Since it's a screen, I have been adding transforms to do it that way instead of using the window show/hide statements, because it will give me more customization in the long run.

Ultimately, I would like to prevent the transitions from showing if the same speaker talks back to back. My idea is to figure out how to define who_old, so that if who_old == who there is no transition but if who_old != who, there is a transition. However, I'm not sure how to do that. Here's what my screen code looks like:

Code: Select all

screen say(who, what):
    if who is None:
        add "gui/namebox.png":
            pos(0.063,0.333)

        window:
            id "middle"
            style "middle"
            text what id "what"

    if who == "b":
        add "GUI/textbox/bottom2.png"
        text what id "what"

    if who == "b3":
        add "GUI/textbox/bottom textbox.png"
        text what id "what"

    if who is not None and who != "b" and who != "b3" and who != playing_as and who != center_voice:
        add "images/Right Tag.png" at nametag_in:
            pos(0,.0151)
        text who id "who"

        window:
            id "right"
            style "right"
            text what id "what"

    if who == center_voice:
        add "gui/namebox.png":
            pos(0.063,0.333)

        text who id "who"

        window:
            id "middle"
            style "middle"
            text what id "what"

    if who == playing_as:
        add "images/Left Tag.png":
            pos(0,0.55)

        window:
            id "left"
            style "left"
            text what id "what"

##textbox transitions (an example of what I'd want)
transform nametag_in:
    alpha 0.0
    pause .05
    alpha 0.4
    ease_quad 0.2 alpha 1.0

transform nametag_out:
    alpha 1.0
    ease .3 alpha 0

transform narration_in:
    alpha 0.0
    ease .2 alpha 1.0
    
transform narration_tag_in:    
    alpha 0.0
    ease .2 alpha 1.0
I'm wondering if there's a way to do something like this (using None as the example):

Code: Select all

    if who is None:
        if who_old == who:
        	add "gui/namebox.png":
           	 pos(0.063,0.333)
        if who_old != who:
        	add "gui/namebox.png" at narration_tag_in ##(then I'd obviously define the exactly transition that I want):
           	 pos(0.063,0.333)
	
        if who_old == who:
    	    window:
    	        id "middle"
     	        style "middle"
       	        text what id "what"
        if who_old != who:
    	    window at narrator_in:
    	        id "middle"
     	        style "middle"
       	        text what id "what"
TL;DR, I want to control when transitions show or not with my textboxes in the say screen to ensure that transitions only happen if the same speaker doesn't speak back to back. Is this possible?

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

Re: Sometimes prevent dialogue transitions in say screen?

#2 Post by Alex » Tue Apr 05, 2022 3:27 pm

You could modify say screen like

Code: Select all

default who_old = "---"

transform scr_tr(t=0.5):
    yanchor 0.0
    linear t yanchor 1.0
    
screen say(who, what):
    # change who_old on dismiss
    key 'dismiss' action[SetVariable('who_old', who), Return()]
    
    text "who_old is [who_old]" align(0.5, 0.05) # just for test
    
    style_prefix "say"

    window:
        if who != who_old: # use transform for new sayer
            at scr_tr()
            
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"

Code: Select all

# The game starts here.
label start:
    "123"
    "456"
    e "abcd"
    "789"
    e "efgh"
    e "ijkl"
    "012"
    jump start

https://www.renpy.org/doc/html/screens.html#key
https://www.renpy.org/doc/html/keymap.html#keymap
https://www.renpy.org/doc/html/screen_a ... tml#Return
https://www.renpy.org/doc/html/screen_a ... etVariable

lindsay-jb
Regular
Posts: 61
Joined: Tue Aug 25, 2020 1:05 am
Contact:

Re: Sometimes prevent dialogue transitions in say screen?

#3 Post by lindsay-jb » Wed Apr 06, 2022 2:09 am

This is great, thank you so much!! :D

One last question, I know how to use the transforms on show but is there a way I could program it to use a separate transform when the boxes leave, instead of then just disappearing? I know there’s an on hide statement but I haven’t pieced together how to do it in this context.

jeffster
Regular
Posts: 123
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Sometimes prevent dialogue transitions in say screen?

#4 Post by jeffster » Wed Apr 06, 2022 1:45 pm

I noticed too that trying to use animation transforms "on hide" doesn't work.

It's probably because (as the interaction ends) the next dialogue line shows immediately, so we just don't see the transform.

One way to circumvent this might be to show the "exit transform" as a first part of the next "entrance transform".

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Sometimes prevent dialogue transitions in say screen?

#5 Post by Ocelot » Wed Apr 06, 2022 6:07 pm

IIRC during normal advancement say screen is never hidden it is only replaced.
< < insert Rick Cook quote here > >

jeffster
Regular
Posts: 123
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Sometimes prevent dialogue transitions in say screen?

#6 Post by jeffster » Wed Apr 06, 2022 7:17 pm

Ocelot wrote:
Wed Apr 06, 2022 6:07 pm
IIRC during normal advancement say screen is never hidden it is only replaced.
Maybe, but "on replace" and "on replaced" don't seem to work either.

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

Re: Sometimes prevent dialogue transitions in say screen?

#7 Post by Alex » Fri Apr 08, 2022 5:49 pm

lindsay-jb wrote:
Wed Apr 06, 2022 2:09 am
This is great, thank you so much!! :D

One last question, I know how to use the transforms on show but is there a way I could program it to use a separate transform when the boxes leave, instead of then just disappearing? I know there’s an on hide statement but I haven’t pieced together how to do it in this context.
Kind of workaround:
- in options.rpy set the window show transition to None and window hide transition to something similar to textbox out transform, like

Code: Select all

## Transitions used to show and hide the dialogue window

define config.window_show_transition = None #Dissolve(.2)
define config.window_hide_transition = slideawayright #Dissolve(.2)
- modify the say screen

Code: Select all

image red:
    Solid("#c00")
    size(100, 100)
    
image green:
    Solid("#0c0")
    size(100, 100)
    
image blue:
    Solid("#00c")
    size(100, 100)

default who_old = "---"

transform enter_scr_tr(t=0.5): # textbox move in
    xpos 0.0 xanchor 1.0
    linear t xanchor 0.0
    
transform exit_scr_tr(t=0.5): # textbox move out
    xpos 0.0 xanchor 0.0
    linear t xpos 1.0

                

screen say(who, what):
    # get the previous sayer
    if _history_list:
        $ old_sayer = _history_list[-1]
    else:
        $ old_sayer = None
    
    key 'dismiss' action[SetVariable('who_old', who), Return()]
    
    style_prefix "say"
    
    # if previous sayer wasn't the same as current
    # show previous sayer window with move out transition
    if old_sayer and old_sayer.who != who:
        window:
            at exit_scr_tr()
                
            id "window"
            ####
            # doesn't need this section
            # if all sayers share the same textbox,
            # but if textbox depends of the length of text
            # lets calculate its appearence
            if len(old_sayer.what) > 10:
                background 'red'
            elif len(old_sayer.what) > 1:
                background 'blue'
            else:
                background 'green'
            #
            ####


            if old_sayer.who is not None:

                window:
                    id "namebox"
                    style "namebox"
                    text old_sayer.who id "who"

            text old_sayer.what id "what"

    window:
        if who != who_old: # use transform for new sayer
            at enter_scr_tr()
            
        id "window"
        ####
        # doesn't need this section
        # if all sayers share the same textbox,
        # but if textbox depends of the length of text
        # lets calculate its appearence
        
        # 'window hide' command hides an empty textbox,
        # so its appearence depends of length of last sayer text
        if len(what) == 0:
            if len(old_sayer.what) > 10:
                background 'red'
            elif len(old_sayer.what) > 1:
                background 'blue'
            else:
                background 'green'
        # appearence of current textbox
        elif len(what) > 10:
            background 'red'
        elif len(what) > 1:
            background 'blue'
        else:
            background 'green'
        #
        ####

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"

        text what id "what"


    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0
- and use it like

Code: Select all

# The game starts here.
label start:
    "Blah-blah"
    e "Blah-blah-blah 2"
    e "Blah-blah-blah 3"
    "Blah-blah 4"
    "Blah-blah-blah 5"
    window hide
    # reset sayer to make textbox appear again with transition
    $ who_old = "---"
    $ renpy.pause()
    "Blah-blah-blah 6"
    "Blah-blah-blah 7"
    e "Blah-blah-blah 8"
    "?!"
    "."
    
    jump start
Also check this sample - viewtopic.php?f=8&t=20975#p269905 :wink:


https://www.renpy.org/doc/html/transiti ... l#CropMove
https://www.renpy.org/doc/html/history.html#
(also, check screen history in screens.rpy)

Post Reply

Who is online

Users browsing this forum: enaielei, Google [Bot]