Slow text in a Screen - Inconsistent behavior

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
DizzyKa
Newbie
Posts: 15
Joined: Sat Sep 24, 2016 4:49 pm
Projects: @GossamerAcademy
Contact:

Slow text in a Screen - Inconsistent behavior

#1 Post by DizzyKa » Fri Mar 17, 2017 5:25 pm

Hey all,

I have a similar problem to viewtopic.php?f=8&t=37922&hilit=slow+text+screen, but the issue is happening inside a screen for me. I'm hoping it's user error on my part.

My text declarations are inside a screen and look like this:

Code: Select all

screen some_screen:
    window:
        fixed:
            showif tab == 1:
                if selected_item > 0:
                    text item_name color (255, 216, 0) min_width 200 text_align 0.5 slow True slow_cps 20 font locker_font size 12 xpos (320.0 / 1280.0) ypos (166.0 / 720.0)
                    text item_desc color (255, 255, 255) slow True slow_cps 20 font locker_font size 10 area ((330.0 / 1280.0), (281.0 / 720.0), 185, 360)
The first time the screen opens the text displays slowly as intended. However, when I change the text ( when a user clicks a new item ) the new text appears immediately. Is there a way to have the text display slowly every time the text is changed?

Thanks!

User avatar
ISAWHIM
Veteran
Posts: 302
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: Slow text in a Screen - Inconsistent behavior

#2 Post by ISAWHIM » Sun Mar 19, 2017 7:30 am

I assume it is "catching" the end-display. That code would only fire again, if the window was "displayed" again, after being hidden.

Thus, once it displays the "slow text", you are just altering the "finished displayed text" to be another set of text. As opposed to processing it again.

I would suggest making the "text display code", be a function, or put that code within an inner-window of that window. Then hide the old slow-text, and set and SHOW the inner-window again... That should re-trigger the code to run.

(You can just hide and show that window too. With the new text set between the hide and show...)

Code: Select all

label update_item_info(new_name, new_desc):
    some_screen hide
    item_name = new_name
    item_desc = new_desc
    some_screen show

#Testing
call update_item_info("Gun", "A weapon to shoot with.")
pause(100)
call update_item_info("Knife", "A weapon to stab with.")
I am not sure if it will give you an error if you try to hide a window that isn't shown... You may want an IF statement there, if that is the case... Since the first time you fire that function, it will not be "shown" to be able to be "hidden"...

The CALL would be the action of the selected items event, so it updates when you select something... I just put it like this, for an example.

User avatar
DizzyKa
Newbie
Posts: 15
Joined: Sat Sep 24, 2016 4:49 pm
Projects: @GossamerAcademy
Contact:

Re: Slow text in a Screen - Inconsistent behavior

#3 Post by DizzyKa » Mon Mar 20, 2017 6:20 pm

Ah that worked beautifully. Great idea, thank you! : )

For anyone wondering in the future I made a screen that only displayed the text of the chosen item, then I hide that screen and show it on button press.

Here's my stripped down script:

Code: Select all

screen selected_item_info(selected_item):
    fixed:
        if selected_item >= 0 and selected_item < item_count:
            text item_name color (255, 216, 0) min_width 200 text_align 0.5 slow True slow_cps 20 font locker_font size 12 xpos (320.0 / 1280.0) ypos (166.0 / 720.0)
            text item_desc color (255, 255, 255) slow True slow_cps 20 font locker_font size 10 area ((330.0 / 1280.0), (281.0 / 720.0), 185, 360)
            text use_string color (255, 216, 0) min_width 132 text_align 0.5 font locker_font size 14 xpos (353.0 / 1280.0) ypos (589.0 / 720.0)

screen character_record():    
    # Ensure this replaces the main menu.
    tag menu
    
    default cur_tab = 0
    default selected_item = -1
    
    window:        
        fixed:
            # Hide the selected item text when we switch to a different tab, there are N more of these buttons but I only left 1 for readability.
            imagebutton auto "images/ui/charrec_char_button_%s.png" xpos (795 / 1280.0) ypos (76 / 720.0) action [SelectedIf(cur_tab==0), Hide('selected_item_info'), SetScreenVariable('cur_tab', 0)] 

        showif tab == 1:
            fixed:
                for i in range(0, 21):
                    # Set up a bunch of stuff for each inventory space.   
                    # Each inventory button hides, then shows the details screen which resets the slow text!
                    imagebutton xpos cur_x ypos cur_y idle item_pic hover item_pic action [SelectedIf(selected_item==i), SetScreenVariable('selected_item', cust_index), Hide('selected_item_info'), ShowMenu('selected_item_info', cust_index)]


Post Reply

Who is online

Users browsing this forum: No registered users