Skip to content

SaveAccessor

Amethyst-szs edited this page Nov 30, 2023 · 5 revisions

What is the SaveAccessor

The save accessor is your one stop shop for writing and reading your save data! When enabling the plugin, this class is registered as an autoload. The whole thing can be managed by a couple extremely simple functions and signals, detailed below.


Active Save Slot

active_save_slot: int

Member variable storing which save slot index is active. Emits "active_slot_changed" changed to a different value

set_active_slot(index: int)

Sets the "active_save_slot", and emits "active_slot_changed" if the new slot is different


Writing to Disk

write_active_slot()

Writes to the active save slot, and emits "save_slot_complete" when successful

write_slot(index: int)

Writes to a specific save slot index, and emits "save_slot_complete" when successful

write_common()

Writes the common data to disk, and emits "save_common_complete" when successful


Reading from Disk

read_active_slot()

Loads data from the active save slot, and emits "load_slot_complete" when successful

read_slot(index: int)

Loads data from a specific save slot index, and emits "load_slot_complete" when successful

read_common()

Loads data from common data on disk, and emits "load_common_complete" when successful


Checking for saves on Disk

is_active_slot_exist()

Checks if a file exists for the active save slot, does not ensure the data inside is valid

is_slot_exist(index: int)

Checks if a file exists for a specific save slot index, does not ensure the data inside is valid


Signals

thread_busy

Emitted when the SaveAccessor starts reading/writing data on its thread

thread_complete

Emitted when the current save or load is finished, regardless of success

save_slot_complete

Emitted when saving to a slot is completed successfully

save_common_complete

Emitted when saving the common data is completed successfully

load_slot_complete

Emitted when loading a slot is completed successfully

load_common_complete

Emitted when loading the common data is completed successfully

active_slot_changed

Emitted when the active_save_slot is updated to a new, different value

save_error

Emitted when a save call fails

load_error

Emitted when a load call fails