Question: How to make text fade after it's been read?

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
Omega_93
Regular
Posts: 31
Joined: Wed Oct 22, 2014 6:14 pm
Contact:

Question: How to make text fade after it's been read?

#1 Post by Omega_93 » Fri Oct 31, 2014 1:32 pm

Like this: https://www.youtube.com/watch?v=dg3sZOG-EjE
I really like the effect and can't for the life of me figure out how the hell to do it...
Any ideas?

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

Re: Question: How to make text fade after it's been read?

#2 Post by Alex » Sat Nov 01, 2014 11:47 am

Try:

Code: Select all

screen nvl:

    $ global new_dialogue
    $ new_dialogue = dialogue

    window:
        style "nvl_window"

        has vbox:
            style "nvl_vbox"

        # Display dialogue.
        if say_lock == False:
            $ index = 0
            if len(dialogue) > 2:
                for who, what, who_id, what_id, window_id in new_dialogue:
                    if index < len(new_dialogue)-2:
                        window:
                            id window_id

                            has hbox:
                                spacing 10

                            if who is not None:
                                text who id who_id at my_fade

                            text what id what_id at my_fade
                            
                            $ index += 1
                            
                    elif index < len(new_dialogue)-1:
                        
                        window:
                            id window_id

                            has hbox:
                                spacing 10

                            if who is not None:
                                text who id who_id at my_tr

                            text what id what_id at my_tr
                            
                            $ index += 1
                            
                    else:
                        window:
                            id window_id

                            has hbox:
                                spacing 10

                            if who is not None:
                                text who id who_id

                            text what id what_id
            
            elif len(dialogue) > 1:
                for who, what, who_id, what_id, window_id in new_dialogue:
                    if index < len(new_dialogue)-1:
                        window:
                            id window_id

                            has hbox:
                                spacing 10

                            if who is not None:
                                text who id who_id at my_tr

                            text what id what_id at my_tr
                            $ index += 1
                            
                    else:
                        window:
                            id window_id

                            has hbox:
                                spacing 10

                            if who is not None:
                                text who id who_id

                            text what id what_id
                        
            else:
                for who, what, who_id, what_id, window_id in new_dialogue:
                    window:
                        id window_id

                        has hbox:
                            spacing 10

                        if who is not None:
                            text who id who_id

                        text what id what_id
                        
        else:
            $ index = 0            
            if len(old_dialogue) > 1:
                for who, what, who_id, what_id, window_id in old_dialogue:
                    if index < len(old_dialogue)-1:
                        
                        window:
                            id window_id

                            has hbox:
                                spacing 10

                            if who is not None:
                                text who id who_id at my_fade

                            text what id what_id at my_fade

                            $ index += 1
                            
                    else:
                        window:
                            id window_id

                            has hbox:
                                spacing 10

                            if who is not None:
                                text who id who_id

                            text what id what_id
                        
            else:
                for who, what, who_id, what_id, window_id in old_dialogue:
                    window:
                        id window_id

                        has hbox:
                            spacing 10

                        if who is not None:
                            text who id who_id

                        text what id what_id
                        

        # Display a menu, if given.
        if items:

            vbox:
                id "menu"

                for caption, action, chosen in items:

                    if action:

                        button:
                            style "nvl_menu_choice_button"
                            action action

                            text caption style "nvl_menu_choice"

                    else:

                        text caption style "nvl_dialogue"

    add SideImage() xalign 0.0 yalign 1.0

    use quick_menu

transform my_fade:
    alpha 0.5
    
transform my_tr:
    linear 0.5 alpha 0.5
        
init python:
    config.empty_window = nvl_show_core
    
    def say_aware(event,interact,type):
        global old_dialogue
        global new_dialogue
        global say_lock
        if event == "begin":
            say_lock = False
        if event == "end":
            say_lock = True
            old_dialogue = new_dialogue

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8", kind=nvl, callback=say_aware)
define narrator = Character(None, kind=nvl, callback=say_aware)

# The game starts here.
label start:
    #window show
    scene black
    "Hello, Eileen."
    window show     # if needed place it after line of text
    e "Hi!"
    scene expression Solid ("#c00") with Dissolve (1.0)
    "... some bg changes ..."
    "????"
    nvl clear
    
    "Some other text"
    "..."
thanks to Kinsman http://lemmasoft.renai.us/forums/viewto ... 75#p269905

Omega_93
Regular
Posts: 31
Joined: Wed Oct 22, 2014 6:14 pm
Contact:

Re: Question: How to make text fade after it's been read?

#3 Post by Omega_93 » Sat Jan 03, 2015 3:24 pm

Any wizards around here know why Alex's script isn't working?
Getting the errors:
File "renpy/common/00nvl_mode.rpy, line 285, in do_display
**display_args)
File "game/script.rpy",line 32, in say_aware
old_dialogue = new_dialogue
NameError: global name 'new_dialogue' is not defined

Thanks

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Question: How to make text fade after it's been read?

#4 Post by xela » Sat Jan 03, 2015 3:40 pm

You prolly didn't define the variable. Like:

Code: Select all

new_dialouge = ""
Code is a bit messy as well :(
Like what we're doing? Support us at:
Image

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Question: How to make text fade after it's been read?

#5 Post by xela » Sat Jan 03, 2015 4:38 pm

Add somewhere:

Code: Select all

transform my_fade(t, alpha):
    alpha 1.0
    linear t alpha alpha
Replace similar bit in screens.rpy file with:

Code: Select all

        # Display dialogue.
        for who, what, who_id, what_id, window_id in dialogue:
            $ index = dialogue.index((who, what, who_id, what_id, window_id))
            $ l = len(dialogue)
            window:
                id window_id

                has hbox:
                    spacing 10
                    
                if index == l - 1:
                    $ pass
                elif index == l - 2:
                    at my_fade(1, 0.5)
                else:
                    at my_fade(0, 0.5)

                if who is not None:
                    text who id who_id

                text what id what_id
Like what we're doing? Support us at:
Image

Omega_93
Regular
Posts: 31
Joined: Wed Oct 22, 2014 6:14 pm
Contact:

Re: Question: How to make text fade after it's been read?

#6 Post by Omega_93 » Sat Jan 03, 2015 5:09 pm

After several months getting angry with a piece of code, desperately trying to learn ren'py to figure out why it wasn't working, only for it to turn out the solution was something as simply as adding: " " ... It's somewhat bitter sweet.
-_-
Thank you ever so much, Xela!


I don't know if this wants to be added to the "cookbook" or something, but we have ourselves a working "read text fade"

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Question: How to make text fade after it's been read?

#7 Post by xela » Sat Jan 03, 2015 5:16 pm

Omega_93 wrote:After several months getting angry with a piece of code, desperately trying to learn ren'py to figure out why it wasn't working, only for it to turn out the solution was something as simply as adding: " " ... It's somewhat bitter sweet.
-_-
Thank you ever so much, Xela!


I don't know if this wants to be added to the "cookbook" or something, but we have ourselves a working "read text fade"

In case it wasn't clear. There is no need to define new globals, callback function, two transforms and a new screen with endless if/else forks. 11 lines of added code from my second post do the same thing. They were not meant as an addon to the previous code, they were meant to replace it completely.
Like what we're doing? Support us at:
Image

Omega_93
Regular
Posts: 31
Joined: Wed Oct 22, 2014 6:14 pm
Contact:

Re: Question: How to make text fade after it's been read?

#8 Post by Omega_93 » Sat Jan 03, 2015 5:47 pm

No no, I understood that you meant to replace some code, I just didn't get what you meant to replace. So I tried your first suggestion of simply adding the " " to the code and the code by Alex worked.
What needed to be replaced? And what's the difference, if you don't mind me asking?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Question: How to make text fade after it's been read?

#9 Post by xela » Sat Jan 03, 2015 7:26 pm

I am not sure that there is a big difference other than length.

You need to open screens.rpy file, find nvl screen and copy/paste the code over the bit that starts with:

Code: Select all

# Display dialogue.
Transform can be placed in any file.
Like what we're doing? Support us at:
Image

User avatar
shivanshs9
Regular
Posts: 54
Joined: Sun Jul 20, 2014 1:59 pm
Projects: The Destiny(http://thedestiny-cxz.blogspot.com)
Organization: Cyber-X-Zone
Location: India
Contact:

Re: Question: How to make text fade after it's been read?

#10 Post by shivanshs9 » Sun Jan 04, 2015 9:53 am

You're awesome, Xela! I was using the same code from Kinsman, but your code's definitely more neat, simple, short and easy to understand! 5 stars for your code!
"Destiny is a no matter of chance
It is a matter of choice
It is not a thing to be waited for
It is a thing to be achieved..."

-William Jennings Bryan
If you can dream and not make dreams your master;
If you can think and not make thoughts your aim,
If you can meet with Triumph and Disaster;
And treat those two impostors just the same,
Only then can you ever win against yourself...

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_