SaveSystem - stingray.SaveSystem namespace reference - Stingray Lua API Reference

stingray.SaveSystem namespace reference

Description

The interface to access the save and load functionality.

Note that this object is a singleton (there is only one SaveSystem), so you do not need to pass any SaveSystem object to the functions. All the functions operate on the SaveSystem singleton.

You can save the following data types:

Asynchronous operations return a SaveToken object that is used to fetch progress during the operation. This object must be closed to free the memory that is used during the save. Otherwise, the game will eventually run out of memory.

On Windows and iOS, you must set up a root directory in which the save system will read and write files. You do this in the settings.ini file for your project, in the platform-specific save_dir setting. For example:

win32 = {
    // ... other windows settings go here
    save_dir = "%APPDATA%\\MyCompany\\MyProjectName\\Saves"
}
iOS = {
    // ... other iOS settings go here
    save_dir = "%SAVEDATA%/MyProjectName"
}

See the settings.ini file reference for more information.

Windows, iOS, and Android

The interface described here is specific to Windows, Mac OS X, iOS, and Android platforms.

Parameters

filename :

string

The name of the file that contains the data you want to load. You do not need to specify a directory. Only a-z, 0-9, and _ characters are allowed in the filename.

Returns

stingray.SaveToken

A token that you can query by calling progress().

The file is silently read.

Note that you must call stingray.SaveSystem.close() on the returned token in order to release the memory allocated by the operation.

Parameters

filename :

string

The name of the file that will contain the saved data. You do not need to specify a directory. Only a-z, 0-9, and _ characters are allowed in the filename. The file is silently overwritten if it exists.

data :

table

Generally, this is a table that contains the data that needs to be saved.

Returns

stingray.SaveToken

A token that you can query by calling progress().

Note that you must call stingray.SaveSystem.close() on the returned token in order to release the memory allocated by the operation.

Parameters

token :

stingray.SaveToken

The SaveToken you want to close.

Returns
This function does not return any values.

This frees the memory used by the operation.

Parameters
This function does not accept any parameters.
Returns

boolean

Returns true if the SaveSystem interface is available for use, or false otherwise.

Parameters

token :

stingray.SaveToken

The token that identifies the operation you want to query.

Returns

save_system_progress

A table that contains information about the progress of the save or load operation, as well as the data loaded (if any).