How do I force an autosafe in renpy at a specific point?

Acehole_Studios

Newbie
Game Developer
Nov 23, 2018
61
144
My game is put together in episodes. Each episode is a different script file. At the end of the current episode it returns and goes to the credits file. I would like to force an autosave to happen before the credits so the player can just pick right up where the story left off.

I found this but it doesn't work:

renpy.force_autosave(take_screenshot=False, block=False)
Forces a background autosave to occur.

take_screenshot If True, a new screenshot will be taken. If False, the existing screenshot will be used. block If True, blocks until the autosave completes.

Thanks in advance!
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,263
I think that just causes an autosave when there is a choice in the game. My episodes don't end in a choice. Or do I need that config to make the other code I found work?
force autosave was disabele in renpy a long time ago, so the only option currently is a choice
 

Acehole_Studios

Newbie
Game Developer
Nov 23, 2018
61
144
force autosave was disabele in renpy a long time ago, so the only option currently is a choice
So would it be better to ask the player, Do you want to save? yes or no? If I did that I would rather the yes go to the save screen like they clicked save. Now I need to see if I can figure that out. Unless there is a better way to handle this?
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,263
If it's a critical point that needs a save, yes it's best to ask the player to do a full save. autosaves are unreliable, overwritten...
 

I'm Not Thea Lundgren!

AKA: TotesNotThea
Donor
Jun 21, 2017
6,582
18,944
I think that just causes an autosave when there is a choice in the game. My episodes don't end in a choice. Or do I need that config to make the other code I found work?
How about a fake choice? Something like "This is the end of the episode, do you want more? Save now" then a button saving "Save" and another saying "Yes, I want more" which automatically saves.
 

Sam

Sysadmin
Staff member
Administrator
Dec 22, 2016
2,614
18,102
You can force an autosave with:
Code:
renpy.force_autosave()
here. What issues did you have when using it? Any errors? What happens when you try:

Code:
renpy.force_autosave(True, True)
 

Acehole_Studios

Newbie
Game Developer
Nov 23, 2018
61
144
How about a fake choice? Something like "This is the end of the episode, do you want more? Save now" then a button saving "Save" and another saying "Yes, I want more" which automatically saves.
If I add a save choice in the game I will have to leave it there when I add the next episode and then I will have to add it again for each episode. I think that will annoy the player. I think the game DOD pulled off what I'm trying to do but then again maybe that was before they disabled the force save code.
 

I'm Not Thea Lundgren!

AKA: TotesNotThea
Donor
Jun 21, 2017
6,582
18,944
If I add a save choice in the game I will have to leave it there when I add the next episode and then I will have to add it again for each episode. I think that will annoy the player. I think the game DOD pulled off what I'm trying to do but then again maybe that was before they disabled the force save code.
A lot of games just have a "This is the end of the episode, save now" message, that seems to work.
 
  • Like
Reactions: Acehole_Studios

Acehole_Studios

Newbie
Game Developer
Nov 23, 2018
61
144
You can force an autosave with:
Code:
renpy.force_autosave()
here. What issues did you have when using it? Any errors? What happens when you try:

Code:
renpy.force_autosave(True, True)
If I just use
renpy.force_autosave(True, True)
I get this from the start:
Code:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/episode3.rpy", line 585: expected statement.
    renpy.force_autosave(True, True)
                                    ^

Ren'Py Version: Ren'Py 7.1.1.929
Sat Jan 18 16:08:28 2020



If I use $renpy.force_autosave(True, True)
the game starts but crashs when it gets to the code

Code:
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 115, in script call
    call episode3 from _call_episode3
  File "game/episode3.rpy", line 585, in script
    $renpy.force_autosave(True, True)
  File "game/episode3.rpy", line 585, in <module>
    $renpy.force_autosave(True, True)
TypeError: force_autosave() takes at most 1 argument (2 given)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 115, in script call
    call episode3 from _call_episode3
  File "game/episode3.rpy", line 585, in script
    $renpy.force_autosave(True, True)
  File "D:\renpy\renpy-7.0.0-sdk\renpy\ast.py", line 882, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\renpy\renpy-7.0.0-sdk\renpy\python.py", line 1913, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/episode3.rpy", line 585, in <module>
    $renpy.force_autosave(True, True)
TypeError: force_autosave() takes at most 1 argument (2 given)

Windows-8-6.2.9200
Ren'Py 7.1.1.929
Pink Prescriptions 0.2.1
Sat Jan 18 16:06:11 2020
 

Sam

Sysadmin
Staff member
Administrator
Dec 22, 2016
2,614
18,102
If I just use
renpy.force_autosave(True, True)
I get this from the start:
Code:
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/episode3.rpy", line 585: expected statement.
    renpy.force_autosave(True, True)
                                    ^

Ren'Py Version: Ren'Py 7.1.1.929
Sat Jan 18 16:08:28 2020



If I use $renpy.force_autosave(True, True)
the game starts but crashs when it gets to the code

Code:
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 115, in script call
    call episode3 from _call_episode3
  File "game/episode3.rpy", line 585, in script
    $renpy.force_autosave(True, True)
  File "game/episode3.rpy", line 585, in <module>
    $renpy.force_autosave(True, True)
TypeError: force_autosave() takes at most 1 argument (2 given)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 115, in script call
    call episode3 from _call_episode3
  File "game/episode3.rpy", line 585, in script
    $renpy.force_autosave(True, True)
  File "D:\renpy\renpy-7.0.0-sdk\renpy\ast.py", line 882, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\renpy\renpy-7.0.0-sdk\renpy\python.py", line 1913, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/episode3.rpy", line 585, in <module>
    $renpy.force_autosave(True, True)
TypeError: force_autosave() takes at most 1 argument (2 given)

Windows-8-6.2.9200
Ren'Py 7.1.1.929
Pink Prescriptions 0.2.1
Sat Jan 18 16:06:11 2020
You're using quite an old version of renpy, what happens when you try against the latest version?

For reference, here is the force_autosave() function in renpy's core:
 

Acehole_Studios

Newbie
Game Developer
Nov 23, 2018
61
144
You're using quite an old version of renpy, what happens when you try against the latest version?

For reference, here is the force_autosave() function in renpy's core:
I was worried about upgrading while developing the game. I didn't want it to break anything. I could upgrade and see what happens. I'm sure I'm missing all kinds of features.

I looked for save features in my renpy code and never saw what you posted. If that is in the new core, maybe upgrading is the answer.
 

Sam

Sysadmin
Staff member
Administrator
Dec 22, 2016
2,614
18,102
I was worried about upgrading while developing the game. I didn't want it to break anything. I could upgrade and see what happens. I'm sure I'm missing all kinds of features.

I looked for save features in my renpy code and never saw what you posted. If that is in the new core, maybe upgrading is the answer.
There can be issues when upgrading, although for the most part they're quite rare. Keep a backup of your old sdk version just to be on the safe side.
 

Acehole_Studios

Newbie
Game Developer
Nov 23, 2018
61
144
There can be issues when upgrading, although for the most part they're quite rare. Keep a backup of your old sdk version just to be on the safe side.
Is there a place I can download my old version if I need to go back?
 

Acehole_Studios

Newbie
Game Developer
Nov 23, 2018
61
144
I'm going to upgrade renpy before trying anything else. Thank you to everyone on here trying to help me out.

I never got this to work:

define config.autosave_on_choice = True

but I guess it cause there is another part that I don't understand how to use.
If True, Ren'Py will autosave upon encountering an in-game choice. (When is called.)


Ok, upgrade first.