Ren'Py Need help rolling back before while loop in Ren'Py [Solved with alternate solution]

wurg

Active Member
Modder
Apr 19, 2018
705
1,630
I'm playing around with a game that uses still images for animation using renpy.pause in between the images. I decided to try and do the animations in the code with a while loop, to make them longer or shorter, the problem is I can't figure out how to allow the user to rollback before the while loop starts. The game will rollback to the start of the while loop but not the line of dialogue before it. I assumed it was filling up the rollback buffer so I used define config.hard.rollback_limit = 1000 in the script file, and it didn't help to rollback before the while loop starts.

I tried messing around with renpy.checkpoint before the while loop, but not completely understanding the mechanics of it, I couldn't get it to make a difference.

Does Ren'Py just not like while loops and this is why I don't see them in games, or is this something that can be mitigated? Any help would be appreciated.
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,058
You would probably be better using the to create varying animations of different lengths and then only call the animation in question when you want to show it.

Python:
#Define Image somewhere in code
image exampleanimation:
    "pathtoimage/830.png"
    pause 0.15
    "pathtoimage/831.png"
    pause 0.15
    "pathtoimage/832.png"
    pause 0.15
    "pathtoimage/833.png"
    pause 0.30
    "pathtoimage/832.png"
    pause 0.15
    "pathtoimage/831.png"
    pause 0.15
    "pathtoimage/830.png"
    pause 0.15
    "pathtoimage/829.png"
    pause 0.15
    "pathtoimage/830.png"
    repeat
#Where you want to use it.
scene exampleanimation
pause #Stop until user clicks.
 

wurg

Active Member
Modder
Apr 19, 2018
705
1,630
You would probably be better using the to create varying animations of different lengths and then only call the animation in question when you want to show it.

Python:
#Define Image somewhere in code
image exampleanimation:
    "pathtoimage/830.png"
    pause 0.15
    "pathtoimage/831.png"
    pause 0.15
    "pathtoimage/832.png"
    pause 0.15
    "pathtoimage/833.png"
    pause 0.30
    "pathtoimage/832.png"
    pause 0.15
    "pathtoimage/831.png"
    pause 0.15
    "pathtoimage/830.png"
    pause 0.15
    "pathtoimage/829.png"
    pause 0.15
    "pathtoimage/830.png"
    repeat
#Where you want to use it.
scene exampleanimation
pause #Stop until user clicks.
That scene would repeat until the user actually clicks wouldn't it, it could be infinite? It could also be used with renpy.pause(delay = 10) so the user can't accidentally click through the animation couldn't it?
Code:
scene exampleanimation
$ renpy.pause ( delay = 10)
I think this is the one that forces a pause in the game, I can't remember if you have to use it with hard=True or not.
This would pretty much the same as using the while loop wouldn't it?
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,058
$ renpy.pause(delay=10,hard=True) would force a user to not be able to click for 10 seconds yes.

For rollback purposes using the image statement with atl is not the same as a while loop... now why they're different I don't know exactly :cry:. My guess is that because this is ren'py script vs a direct python command that there is trickery going on that causes the loops to register as 1 action for the rollback limit.
 
  • Like
Reactions: wurg

wurg

Active Member
Modder
Apr 19, 2018
705
1,630
$ renpy.pause(delay=10,hard=True) would force a user to not be able to click for 10 seconds yes.

For rollback purposes using the image statement with atl is not the same as a while loop... now why they're different I don't know exactly :cry:. My guess is that because this is ren'py script vs a direct python command that there is trickery going on that causes the loops to register as 1 action for the rollback limit.
Thank you I got it to work with your method, the only hiccup is making the dialog box disappear again when a line of dialog shows up in the middle of the scene. The only way I could find to make it go away is this, I don't know if there is a better way or not. That stupid dialog box is the bane of my existence.
Code:
    $ renpy.pause(.01)
    scene hotelAnimation
    $ renpy.pause ( 5, hard = True)
    e   "Yes! Yes! Don't stop!"
    scene hotelAnimation
    $ renpy.pause (.01)
    $ renpy.pause ( 5, hard = True )
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,058
No problem, instead of using scene every time you can use "window hide" instead.

Like so (Ignore how I positioned and zoomed the image):
Python:
image testanim:
    "anim 1.webp"
    0.15
    "anim 2.webp"
    0.15
    "anim 3.webp"
    0.15
    "anim 4.webp"
    0.15
    "anim 5.webp"
    0.15
    "anim 6.webp"
    0.15
    "anim 7.webp"
    0.15
    "anim 8.webp"
    0.15
    "anim 9.webp"
    0.15
    "anim 10.webp"
    0.15
    "anim 11.webp"
    0.15
    "anim 12.webp"
    0.15
    repeat

label start:
   $ renpy.pause(.01)
   scene testanim with dissolve:
        xalign 0.5
        yalign 0.5
        zoom 2.4
   $ renpy.pause(3,hard=True)
   "YES YES YES"
   window hide
   $ renpy.pause(.01)
   $ renpy.pause(3,hard=True)
   "YES YES YES 2"
   window hide
   $ renpy.pause(.01)
   $ renpy.pause(3,hard=True)
   "YES YES YES 3"
   window hide
   $ renpy.pause(.01)
   $ renpy.pause(3,hard=True)
   "YES YES YES 4"
   window hide
   $ renpy.pause(.01)
   $ renpy.pause(3,hard=True)
   "YES YES YES 5"
   window hide
   $ renpy.pause(.01)
   $ renpy.pause(3,hard=True)
   "YES YES YES 6"
   window hide
   $ renpy.pause(.01)
   $ renpy.pause(3,hard=True)
   "YES YES YES 7"
   window hide
 
  • Like
Reactions: wurg

wurg

Active Member
Modder
Apr 19, 2018
705
1,630
Thank you again, I feel like an idiot now, I learned about window hide not too long ago and completely forgot about it, I was trying to do 'hide say'. That works absolutely perfect. I'm still new to Ren'Py and Python and it's hard trying to remember all of the different commands to do everything, or even the different commands that can do the same thing.
 

wurg

Active Member
Modder
Apr 19, 2018
705
1,630
The code doing the same thing as before:
Code:
    window hide         # to hide the dialog box
    scene hotelAnimation
    $ renpy.pause ( 5, hard = True)     # to hard pause the game so the user can't click through it
    e   "Yes! Yes! Don't stop!"
    window hide             # to hide the dialog box
    $ renpy.pause ( 5, hard = True )    # hard pause so user can't click through animation
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,058
No problem, I had to go look in my project to remember the exact syntax I don't have to use that command very often. :whistle:
 
  • Like
Reactions: wurg