[Solved?] To have "who" with ScrollSay

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
Nice_Smile
Newbie
Posts: 9
Joined: Wed Jun 05, 2019 2:00 pm
Location: Canada
Contact:

[Solved?] To have "who" with ScrollSay

#1 Post by Nice_Smile » Wed Jun 05, 2019 4:09 pm

My first post here!

I have been reading a lot of very useful and helpful posts in this forum. I am amazed how powerful Ren'Py can become. I am currently at a very basic level of knowledge of python but learning very quickly thanks to every one here.

I came across an old thread Link -> "Is this text behaviour possible in Ren'py" and I found it really awesome to implement it into my project. I am using the "ScrollSay.zip" from "Kinsman" Link-> Post# 5 (Thank you by the way! *tip my hat*).

I would like the characters names to appear with the text box on mine. I have followed the instructions written in the "script.rpy" file.

Code: Select all

Comments from the "script.rpy" file of the "ScrollSay.zip"
# You can place the script of your game in this file.

# To move what was done here to your own project:
#
# Copy the bottom part of options.rpy, the three variables
# Copy "say_aware", found here in script.rpy
# Make sure your Character objects have "callback=say_aware" added
# Copy "screen say" in screens.rpy
# Copy "transform say_enter" and "transform say_exit" in screens.rpy

# Copy "crossfade" too, if the character dissolving was important to your project
- I copied the 3 end lines from "options" into mine

Code: Select all

# ScrollSay START

init python:
    old_text = ""
    new_text = ""
    say_lock = True
    
# ScrollSay END
    
- I copied the "say_aware" and "crossfade" lines from "script" into mine:

Code: Select all

# ScrollSay START

init python:
    
    def say_aware(event,interact,type):
        global old_text
        global new_text
        global say_lock
        if event == "begin":
            say_lock = False
        if event == "end":
            say_lock = True
            old_text = new_text
            
    def crossfade(oldface,newface):
        trans = Dissolve(0.5,old_widget=ImageReference(oldface),new_widget=ImageReference(newface),alpha=True)
        return trans()
        
# ScrollSay END
- I made certain that all my Character objects had the "callback=say_aware" added to them:

Code: Select all

define e = Character("Eileen", who_color="#c8ffc8", callback=say_aware)
- I copied "screen say" and "transform say_enter" and "transform say_exit" lines from "screens" into mine:

Code: Select all

# ScrollSay START

transform say_enter:
    alpha 0 yoffset -40
    linear 0.5 alpha 1.0 yoffset 0
    
transform say_exit:
    yoffset 0 alpha 1.0
    linear 0.5 alpha 0.0 yoffset 40

screen say:

    # Defaults for side_image and two_window
    default side_image = None
    default two_window = False
    
    # Let's make the say screen itself simple,
    # discarding things like who and two_window
    
    $global new_text
    $new_text = what
    
    if say_lock == False:
        window:
            id "window"
            text new_text id "what" at say_enter
        window:
            style "say_window"
            background "#0000"
            text old_text style "say_dialogue" at say_exit
    else:
        window:
            id "window"
            text old_text id "what"

# ScrollSay END
below the the last line of the section:

Code: Select all


## Say screen ##################################################################
##
## The say screen is used to display dialogue to the player. It takes two
## parameters, who and what, which are the name of the speaking character and
## the text to be displayed, respectively. (The who parameter can be None if no
## name is given.)
##
## This screen must create a text displayable with id "what", as Ren'Py uses
## this to manage text display. It can also create displayables with id "who"
## and id "window" to apply style properties.
##
## https://www.renpy.org/doc/html/screen_special.html#say

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

    window:
        id "window"

        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 above the line:

Code: Select all

## Make the namebox available for styling through the Character object.

I know in the comments of "# discarding things like who and two_window" that is written in the "screen.rpy" tells me that the "who" is not written. What would be the code that needs to be added to show the "who"?

Thank you for your time!
- edited the title!
Last edited by Nice_Smile on Wed Jun 12, 2019 1:14 am, edited 3 times in total.
Currently using Ren'Py v.7.2.2.491

User avatar
Nice_Smile
Newbie
Posts: 9
Joined: Wed Jun 05, 2019 2:00 pm
Location: Canada
Contact:

Re: To have "who" with ScrollSay

#2 Post by Nice_Smile » Sun Jun 09, 2019 11:30 pm

Update:
Well after a long time entering codes within, this one seems to work for displaying "WHO" into the "screen.rpy"

So many trials and so many errors but seems to work out... for now! LOL
The name shows and it does not scroll, only the text of the dialogue scrolls - which is what I wanted.

Code: Select all

# *********************************************
# SS START
#
# Screen that's used to display adv-mode dialogue.

transform say_enter:
    alpha 0 yoffset -40
    linear 0.5 alpha 1.0 yoffset 0

transform say_exit:
    yoffset 0 alpha 1.0
    linear 0.5 alpha 0.0 yoffset 40

screen say:

    # Defaults for side_image and two_window
    default side_image = None
    default two_window = False

    # Let's make the say screen itself simple,
    # discarding things like who and two_window

    $global new_text
    $new_text = what

    if say_lock == False:
        window:
            id "window"
            text new_text id "what" at say_enter
        window:
            style "say_window"
            background "#0000"
            text old_text style "say_dialogue" at say_exit

## INSERTED THIS HERE ###
        window:
            id "namebox"
            style "namebox"
            xpos 0 ypos 0.75
            text who id "who"
########################
    else:
        window:
            id "window"
            text old_text id "what"

        #has vbox:
        #    style "say_vbox"
# SS END ******************************
To anyone that took the time to read this and tried to help, thank you!
It may not be the prettiest code but it works for me! :)
Currently using Ren'Py v.7.2.2.491

Post Reply

Who is online

Users browsing this forum: Google [Bot], hell_oh_world