pause delay does not work when loading save

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
downover
Regular
Posts: 38
Joined: Sun Feb 25, 2024 1:36 am
Contact:

pause delay does not work when loading save

#1 Post by downover »

Hello! Experienced dev in other engines, new to Ren'Py. I'm helping out on a project and they have a pattern which boils down to:

Code: Select all

    $ renpy.suspend_rollback(True)
    label loop:
        $ renpy.log("In the loop!" + str(datetime.datetime.now()))
        show eileen sad
        pause 1
        show eileen happy
        pause 1
        jump loop
        # the actual game has a listener for a button click that jumps to cont

    label cont:
        $ renpy.suspend_rollback(False)
This pattern is used pretty often to loop through images and play sounds until the user clicks a button. The catch is that, if the user saves during this loop, they get a Possible Infinite Loop Exception on load, because each `pause 1` lasts for a couple ms instead of 1 second. I've modified the sample project to demonstrate. See the readme for full steps to repro and stack. https://github.com/do10HM/bug260/tree/main

As for what to do - this is a large project, so ideally I'd like to find a solution that doesn't involve a major rewrite. My first instinct is to disable saving during these loops, but it looks like that's essentially what `suspend_rollback(true)` should be doing.

Another question is, is this really the best way to do this type of loop? Is there a better pattern?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2438
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: pause delay does not work when loading save

#2 Post by Ocelot »

Link does not work. You probably have created a private github repo instead of public one.
< < insert Rick Cook quote here > >

downover
Regular
Posts: 38
Joined: Sun Feb 25, 2024 1:36 am
Contact:

Re: pause delay does not work when loading save

#3 Post by downover »

Fixed! Sorry about that.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2438
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: pause delay does not work when loading save

#4 Post by Ocelot »

IIRC Renpy fast-forwardsuntil it finds a place requiring interaction from player. The better way would probably be to make animation as an ATL script and display it before loop.

Code: Select all

image eileen sad = Placeholder()
image eileen happy = Placeholder()

image eileen waiting:
    "eileen sad"
    1.0
    "eileen happy"
    1.0
    repeat

    label loop:
        show eileen waiting # moved from loop body, so animation won't restart because of errant clicks
    label .do_loop
        $ renpy.log("In the loop!" + str(datetime.datetime.now()))
        pause # We do not actually care if user clicks, because loop will take us right back
        # Even better solution would be to display a modal screen iver it, so clicks won't interrupt pause
        # THere are multiple ways to stop user from advancing. Some might be better than others.
        jump .do_loop
        # the actual game has a listener for a button click that jumps to cont that I haven't replicated here.
< < insert Rick Cook quote here > >

downover
Regular
Posts: 38
Joined: Sun Feb 25, 2024 1:36 am
Contact:

Re: pause delay does not work when loading save

#5 Post by downover »

Ah, that explains it.

Is there any way to detect that a load has just happened, so we can set it to `pause` instead of `pause 2.3`?

jeffster
Miko-Class Veteran
Posts: 520
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: pause delay does not work when loading save

#6 Post by jeffster »

I don't think that loop is needed at all. To show an animation indefinitely, you just use an animated image,
https://renpy.org/doc/html/atl.html
then "pause".

On certain clicks that pause ends, and you progress further. No need for "suspend_rollback" and no problems with save or load.
And if you need to go back to looping the same image, you do that with the usual script syntax (like "if ... jump").
Is there any way to detect that a load has just happened
"after_load" would probably work:
https://www.renpy.org/doc/html/label.ht ... ial-labels

PS. Also see "Controlling Interactions" in
https://www.renpy.org/doc/html/dialogue ... er-objects

Using "advance" or "interact", you can set a dialog (say screen) to pause not interrupted by regular clicks, or to not pause at all (e.g. using "call screen" that would control the interaction instead of a regular say screen).
If the problem is solved, please edit the original post and add [SOLVED] to the title. 8)

downover
Regular
Posts: 38
Joined: Sun Feb 25, 2024 1:36 am
Contact:

Re: pause delay does not work when loading save

#7 Post by downover »

Thank you so much for your help!

I think an ATL rewrite is the way to go but it's up to the devs of the project. This pattern is used in... 77 places, at least, so coming up with a more generic approach would simplify the codebase.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], W3C [Validator]