Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 3.33 KB

init.markdown

File metadata and controls

49 lines (31 loc) · 3.33 KB

save.init()

 
Type function
Library save.*
Return value nil
Keywords save, init
See also Sample code

Overview

This function is used to initialize the save plugin. The function can be called again to change the parameters, for example to load a different save file, or to use different keys and version numbers for new save file versions (see save.getVersion() for instructions on versioning).

Syntax

save.init( filename, version, crypto_key, hash_key )
filename (required)

String. The save file. Files are save in JSON, so using a .json extension is recommended.

version (required)

Number. The save file version, which is specific to the application. Increment this if the data contained in the save file is modified in a new application version and you need to add version-specific handling. See save.getVersion() for instructions on versioning. See save.getVersion() for instructions on versioning.

crypto_key (required)

Array. The cryptographic key used for making the data more secure. This is an array of 7 integers (any unspecified integers are defaulted to 0).

hash_key (required)

String. The hash key used to encrypt the data. This can be any string, and may be the same for different applications, but it is recommended that it is unique to the application. The data may be made more secure by concatenating an application-specific string with a unique device-specific ID.

disableAlert (optional)

Boolean. Whether to disable the alert dialog generated by save.load() when the keys do not match the save file. Set this to true if you want to implement your own custom behaviour for handling save file tampering. This sets the default behaviour, which can be overridden by parameters passed to save.load().

alertTitle (optional)

String. The alert dialog title text displayed by save.load() when the keys do not match the save file. Defaults to "No cheating!". This sets the default text, which can be overridden by parameters passed to save.load().

alertMessage (optional)

String. The alert dialog message text displayed by save.load() when the keys do not match the save file. Defaults to "Save file has been tampered with, so will be deleted!". This sets the default text, which can be overridden by parameters passed to save.load().

Examples

local save = require 'plugin.save'

save.init( "example.json", 1, {36, 45, 92, 36, 19, 28, 5}, "bveiubv984nw0" )