init +1 python:
def Can_load():
lastsave=renpy.newest_slot() # get the newest slot
CanLoad = renpy.can_load(lastsave, test=False) # check if it can be loaded
print(lastsave)
if lastsave is not None: # prevent crash if '_reload-*' not exist in saves
if '_reload' in lastsave:
return False # if '_reload' in saves, return False.
else:
if CanLoad:
return CanLoad # Return True if the save can be loaded.
else:
return CanLoad # Return False if the save cannot be loaded.
else:
return False
def Load_NewSave():
lastsave=renpy.newest_slot() # Get the newest save slot.
renpy.load(lastsave) # The load the save.
screen ContinueButton():
if Can_load():
textbutton _("Continue") action Function(Load_NewSave)
screen navigation():
use ContinueButton()
# ...
init -999 python:
def newest_slot_tuple():
"""
Returns a tuple with the newest slot page and name.
"""
newest = renpy.newest_slot()
if newest is not None:
page, name = newest.split("-")
return (page, name)
class Continue(Action):
"""
Loads the last save file.
"""
def __call__(self):
if not self.get_sensitive():
return
# Assign variables from the tuple.
newest_page, newest_name = newest_slot_tuple()
# Load the file using the newest slot information.
FileLoad(newest_name, confirm=False, page=newest_page, newest=True)()
def get_sensitive(self):
# Insensitive in-game.
if not main_menu:
return False
# Insensitive during replay mode.
if _in_replay:
return False
# Get the tuple.
newest = newest_slot_tuple()
# Insensitive if no new slot files.
if newest is None:
return False
# Assign variables from the tuple.
newest_page, newest_name = newest
# Insensitive if the newest save is '_reload-*'
if newest_page == '_reload':
return False
# This action returns true if the file is loadable.
return FileLoadable(newest_name, page=newest_page)