Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 2.55 KB

load.markdown

File metadata and controls

52 lines (34 loc) · 2.55 KB

save.load()

 
Type function
Library save.*
Return value Boolean.
Keywords load, save
See also Sample code, save.save()

Overview

This function is used to load data from the save file. The data is then available in the save.data table.

Note that at load time, if the save file has been tampered with, an alert dialog will be shown and the save data will be deleted. This is to prevent cheaters/hackers from tampering with save data.

Syntax

save.load( disableDelete, disableAlert, alertTitle, alertMessage )
disableDelete (optional)

Boolean. Whether to disable deletion of save files whose keys do not match the values passed to save.init(). This is intended for debug purposes, and the save file will not be loaded if it has been tampered with.

disableAlert (optional)

Boolean. Whether to disable the alert dialog generated when the keys do not match the values passed to save.init(). Set this to true if you want to implement your own custom behaviour for handling save file tampering. This temporarily overrides any value passed to save.init().

alertTitle (optional)

String. The alert dialog title text displayed by save.load() when the keys do not match the values passed to save.init(). This temporarily overrides any value passed to save.init().

alertMessage (optional)

String. The alert dialog message text displayed by save.load() when the keys do not match the values passed to save.init(). This temporarily overrides any value passed to save.init().

Examples

local save = require 'plugin.save'

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

if (save.load()) then
	print("Save file loaded")

	if (save.data["field"]) then
		print(save.data["field"])
	end
else
	print("Failed to load save file")
end