Regards Python execution pause for a certain amount of seconds

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
andriodmactemporary
Newbie
Posts: 19
Joined: Mon Jan 25, 2021 5:35 pm
Contact:

Regards Python execution pause for a certain amount of seconds

#1 Post by andriodmactemporary » Tue May 11, 2021 2:55 pm

Here from the code how to pause the code execution for a certain amount of seconds after each line of execution.
If I employ this method program combining all the seconds (2+2+2 = 6 seconds) and pausing the program only once for 6 seconds.

But, I need to pause the program 2 seconds after appending a new message to the array.

This means this has to be like taking time to get a reply message from the receiver.

Code: Select all

import time
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : text})

                time.sleep(2)

                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Fine'})

               time.sleep(2)

                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : "Let's meet somewhere"})

                time.sleep(2)

                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Shop or Office'})
                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-image', 'imagePath' : 'Shop.png'})
                persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-image', 'imagePath' : 'Office.jpg'})
Last edited by andriodmactemporary on Tue May 11, 2021 4:30 pm, edited 1 time in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1072
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Regards Python execution pause for a certain amount of seconds

#2 Post by Ocelot » Tue May 11, 2021 3:03 pm

Well, this code actually works exactly as you want. If you were to inspect list values you would see that they are exactly what you would expect at any given moment.

What you really see is that you probaly do not see any screens redrawing. This is because nothing in the code is telling RenPy "user might notice if screens are not redrawn, get to it". You need to cause an interaction, and time module, not being part of RenPy would not do that.

You probably want to use renpy.pause() function instead.
< < insert Rick Cook quote here > >

andriodmactemporary
Newbie
Posts: 19
Joined: Mon Jan 25, 2021 5:35 pm
Contact:

Re: Regards Python execution pause for a certain amount of seconds

#3 Post by andriodmactemporary » Tue May 11, 2021 4:30 pm

Ocelot wrote:
Tue May 11, 2021 3:03 pm
Well, this code actually works exactly as you want. If you were to inspect list values you would see that they are exactly what you would expect at any given moment.

What you really see is that you probaly do not see any screens redrawing. This is because nothing in the code is telling RenPy "user might notice if screens are not redrawn, get to it". You need to cause an interaction, and time module, not being part of RenPy would not do that.

You probably want to use renpy.pause() function instead.
I have also tried renpy.pause() it is also providing same functionality has time.sleep().

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1072
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Regards Python execution pause for a certain amount of seconds

#4 Post by Ocelot » Wed May 12, 2021 2:45 pm

Is this a part of function or just written in script? Is it a part of a single Python statement?
< < insert Rick Cook quote here > >

andriodmactemporary
Newbie
Posts: 19
Joined: Mon Jan 25, 2021 5:35 pm
Contact:

Re: Regards Python execution pause for a certain amount of seconds

#5 Post by andriodmactemporary » Thu May 13, 2021 4:58 am

Ocelot wrote:
Wed May 12, 2021 2:45 pm
Is this a part of function or just written in script? Is it a part of a single Python statement?
It is wrapped under python block.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1072
Joined: Tue Aug 23, 2016 10:35 am
Skype: miinipaa
Contact:

Re: Regards Python execution pause for a certain amount of seconds

#6 Post by Ocelot » Thu May 13, 2021 5:04 am

Can you replace it with a series of one-line Python statements (and use renpy.pause) and check if it fixes the problem. IIRC python blocks are considered single statement, so there could be your problem.
< < insert Rick Cook quote here > >

andriodmactemporary
Newbie
Posts: 19
Joined: Mon Jan 25, 2021 5:35 pm
Contact:

Re: Regards Python execution pause for a certain amount of seconds

#7 Post by andriodmactemporary » Thu May 13, 2021 10:25 am

Ocelot wrote:
Thu May 13, 2021 5:04 am
Can you replace it with a series of one-line Python statements (and use renpy.pause) and check if it fixes the problem. IIRC python blocks are considered single statement, so there could be your problem.
No use, the same problem is occurring it is waiting entirely for 6 seconds and redrawing the screen.

Here what I have done :

Replaced :-

python:
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : text})

time.sleep(2)

persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Fine'})

time.sleep(2)

persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : "Let's meet somewhere"})

time.sleep(2)

With :-

$persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : text})

$renpy.pause(2)

$persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Fine'})

$renpy.pause(2)

$persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : "Let's meet somewhere"})

$renpy.pause(2)

Post Reply

Who is online

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