(The profile system is largely detailed here... I want to post it to the Cookbook subforum once I have some issues like this one ironed out.)
I'm also using a system that I found to continue from last save, with some additions:
Continue.rpy:
Code: Select all
init -999 python:
def newest_slot_tuple():
"""
Returns a tuple with the newest slot page and name.
"""
if profile_id == 1:
newest = renpy.newest_slot('1')
if profile_id == 2:
newest = renpy.newest_slot('2')
if profile_id == 3:
newest = renpy.newest_slot('3')
if profile_id == 4:
newest = renpy.newest_slot('4')
if newest is not None:
page, name = newest.split("-")
return (page, name)
def forcesave():
renpy.take_screenshot()
if profile_id == 1:
renpy.save("1-1", save_name)
if profile_id == 2:
renpy.save("2-100", save_name)
if profile_id == 3:
renpy.save("3-199", save_name)
if profile_id == 4:
renpy.save("4-298", save_name)
return
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)
screens.rpy:
Code: Select all
for i in range(gui.file_slot_cols * gui.file_slot_rows):
if profile_id == 2:
$ slot_adjust = 99
elif profile_id == 3:
$ slot_adjust = 198
elif profile_id == 4:
$ slot_adjust = 297
else:
$ slot_adjust = 0
Now, I recently added a vbox to my profile buttons to show the filescreenshot of the most recent save, and also wanted to set up a pseudo autosave system, so that the player can't start a profile but not have a save file. Hence the forcesave() function that I added to Continue.rpy. The first slot in each save file group is the designated autosave slot.
Here's an example of the button logic:
Code: Select all
screen playprofiles:
vbox:
imagebutton:
idle "images/interacts/GreenBox.png"
hover Transform("images/interacts/GreenBox.png", matrixcolor=TintMatrix("#66ff3d"))
xpos 320 ypos 270
action [SetVariable("profile_id", 1),FilePage(1),Jump("first")]
if persistent.profile1 == True:
vbox:
text "[persistent.player_name_1]" color "#FFF"
xalign 0.33 yalign 0.31
vbox:
text FileSaveName(renpy.newest_slot('1'), slot = True, page = True) color "#FFF" size 20
xalign 0.33 yalign 0.36
vbox:
image FileScreenshot(renpy.newest_slot('1'), slot = True, page = True)
xalign 0.32 yalign 0.46
at zoomless
Is there a conditional that I could add to my forcesave() function that would only activate the filescreenshot on save but not on load? Or to have it load to just after the point where it initiates the save?