Savegame functions - Grisgram/gml-raptor GitHub Wiki
/// @function savegame_save_game(filename, cryptkey = "")
/// @description Saves the entire game state to a file
/// See docu in Saveable object for full documentation
/// @param {string} filename Relative path inside the working_folder where to save the file
/// @param {string=""} cryptkey Optional. The key to use to encrypt the file
/// If not provided, the file is written in plain text (NOT RECOMMENDED!)
/// @returns {bool} Success of the save operation
/// @function savegame_load_game(filename, cryptkey = "")
/// @description Loads a previously saved game state (see savegame_save_game)
/// @param {string} filename Relative path inside the working_folder to find the file
/// @param {string=""} cryptkey Optional. The same key that has been used to encrypt the file
/// If not provided, the file is expected to be plain text (NOT RECOMMENDED!)
/// @returns {bool} True, if the game loaded successfully, or false, if not
/// @function savegame_exists(_filename)
/// @description Checks, whether the specified savegame exists. Takes the
/// SAVEGAME_FOLDER configuration path into account
/// @returns {bool} True, if the savegame exists, or false, if not.
These functions allow you to add any additional struct data to the savegame.
This struct is in addition to the {data} node! You can store whatever you want in the savegame.
/// @function savegame_add_struct(name, struct)
/// @description Adds any custom struct to the save game.
/// Can be retrieved after loading through savegame_get_struct(name).
/// @param {string} name The name to reference this struct.
/// @param {struct} struct The struct to save.
/// @function savegame_remove_struct(name)
/// @description Removes any custom struct from the save game.
/// @param {string} name The name of the struct. If it does not exist, it is silently ignored.
/// @function savegame_struct_exists(name)
/// @description Checks whether a specified struct exists in the savegame.
/// @param {string} name The name of the struct to find.
/// @returns {bool} True if the struct exists or false if not.
/// @function savegame_get_struct(name)
/// @description Retrieves the specified struct from the savegame.
/// @param {string} name The name of the struct. If it does not exist, [undefined] is returned.
/// @returns {struct} The struct or [undefined] if it does not exist.
See Workflow and User Events for an example when to use these.
/// @function savegame_get_instance_names()
/// @description Gets all stored instance names (= IDs) in the savegame.
/// @returns {array} All instance names in the savegame
/// @function savegame_get_instance_of(old_instance_id)
/// @description Retrieves the specified instance from the savegame.
/// @param {int/str} old_instance_id The original id (when the game was saved) of the object.
/// @returns {struct} The instance or [noone] if it does not exist.
/// @function savegame_get_instance_array_of(id_array)
/// @description Maps an array of object ids to an array of instances.
/// NOTE: Only works with stored ids of savegames
/// through savegame_get_id_array_of!
/// @param {array} id_array An array of object ids.
/// @returns {array} Returns an array containing the ids of the instances (in the same order).
/// @function savegame_get_id_array_of(instance_array)
/// @description Maps an array of object instances to an array of their id's only.
/// Useful if you want to persist linked objects in a savegame.
/// @param {array} instance_array An array of object instances.
/// @returns {array} Returns an array containing the instances (in the same order).