Text History Screen Script with Voice Playback

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
yoyuchi
Regular
Posts: 58
Joined: Sat Jul 09, 2022 1:39 pm
Contact:

Text History Screen Script with Voice Playback

#1 Post by yoyuchi » Sun Oct 09, 2022 2:35 am

I want to play the voice on the text history screen. The current script I'm using contains a voice playback function, but it doesn't work properly. The same voice is played not only for voice text but also for the next non-voice text.

Code: Select all

screen text_history:

    #use navigation
    tag menu     
    $ _window_hide()
    add "grp/parts/readback.png"
    predict False
    if not current_line and len(readback_buffer) == 0:
        $ lines_to_show = []        
    elif current_line and len(readback_buffer) == 0:
        $ lines_to_show = [current_line]        
    elif current_line and not ( ( len(readback_buffer) == 3 and current_line == readback_buffer[-2]) or current_line == readback_buffer[-1]):  
        $ lines_to_show = readback_buffer + [current_line]        
    else:
        $ lines_to_show = readback_buffer    
    $ adj = NewAdj(changed = store_yvalue, step = 300)
    
    window:
        style_group "readback"        
        side "c r":            
            frame:                
                has viewport 
                mousewheel True
                draggable True
                yinitial yvalue
                yadjustment adj
                
                vbox:
                    null height 10                    
                    for line in lines_to_show:                        
                        if line[0] and line[0] != " ":
                            label line[0] # name

                        # if there's no voice just log a dialogue
                        if not line[2]:
                            text line[1]
                            
                        # else, dialogue will be saved as a button of which plays voice when clicked
                        else: 
                            textbutton line[1] action Play("voice", line[2] )
                            text line[1]
                        null height 10
                
            bar adjustment adj style 'vscrollbar'
        imagebutton idle "grp/parts/x_readback_idle.png" hover "grp/parts/x_readback_hover.png" xpos 1559 ypos 55 hover_sound "sound/se/se_01.ogg" action [Play("sound", "sound/se/se_03.ogg"), Return()] 
        key "mouseup_3" action [Play("sound", "sound/se/se_03.ogg"), Return()]  
        key "K_ESCAPE" action [Play("sound", "sound/se/se_03.ogg"), Return()] 
If there is a great person who has a script for a text history screen with a well-functioning voice playback function, I would so appreciate it if you could share it. Or please tell me how to modify the script above.
Thank you in advance for your help.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]