Data
Functions
SaveGame
function Data.SaveGame((bool)UseSameSaveFile)
Parameter | Type | Description |
---|---|---|
UseSameSaveFile | bool |
True/False should this save use the same save file as last time or should it shift the backup numbers so the old save file will be called GardenPaws1.IS and so on? |
Data.SaveGame
Saves the game
Example
Data.SaveGame(true)
SaveJSON
function Data.SaveJSON((string)jsonKey , (string)jsonString)
Parameter | Type | Description |
---|---|---|
jsonKey | string |
This is the key you will use to retrieve your saved data later. |
jsonString | string |
This is the json string you're saving. Make sure to use json.serialize(LuaTable) to serialize it to a string. |
Data.SaveJSON
Saves a json string. Keep in mind that the saves will only actually get saved to file if the player goes to sleep or Data.SaveGame()
is called.
Example
Data.SaveJson("My_Key", json.serialize(MyLuaTable))
json.serialize(LuaTable)
to serialize it to a string.
LoadJSON
function Data.LoadJSON((string)jsonKey , (string)defaultJsonString)
Parameter | Type | Description |
---|---|---|
jsonKey | string |
This is the key you will try to retrive from your saved data. |
defaultJsonString | string |
This is a default json string to use in case it doesn't find a saved json on that key. It can be useful to initialize it with default values to avoid errors. |
Data.LoadJSON
Loads a json string from saved data
Example
MyTable = Data.LoadJson("My_Key", OptionalDefaultJsonString)
myTable = json.parse(resultString)
.
SaveString
function Data.SaveString((string)key , (string)savingString)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key you will use to retrieve your saved data later. |
savingString | string |
This is the string you're saving. |
Data.SaveString
Saves a string. Keep in mind that the saves will only actually get saved to file if the player goes to sleep or Data.SaveGame()
is called.
Example
Data.SaveString("My_Key", "Hello World")
LoadString
function Data.LoadString((string)key , (string)defaultString)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key to retrieve from the saved data. |
defaultString | string |
This is a default string that will be returned in case the key isn't found in the saved data. |
Data.LoadString
Loads a string from the saved data.
Example
Data.LoadString("My_Key", "Didn"t find key")
SaveVector3
function Data.SaveVector3((string)key , (Vector3)savingVector3)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key you will use to retrieve your saved data later. |
savingVector3 | Vector3 |
This is the Vector3 you're saving. |
Data.SaveVector3
Saves a Vector3. Keep in mind that the saves will only actually get saved to file if the player goes to sleep or Data.SaveGame()
is called.
Example
Data.SaveVector3("My_Key", World.NewVector3(0,0,0))
LoadVector3
function Data.LoadVector3((string)key)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key to retrieve from the saved data. |
Data.LoadVector3
Loads a Vector3 from the saved data.
Example
Data.LoadVector3("My_Key")
SaveLuaTable
function Data.SaveLuaTable((string)key , (Table)savingTable)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key you will use to retrieve your saved data later. |
savingTable | Table |
This is the lua table you're saving. |
Data.SaveLuaTable
Saves a Lua Table. Keep in mind that the saves will only actually get saved to file if the player goes to sleep or Data.SaveGame()
is called.
Example
Data.SaveLuaTable("My_Key", LuaTable)
LoadLuaTable
function Data.LoadLuaTable((string)key)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key to retrieve from the saved data. |
Data.LoadLuaTable
Loads a lua table from the saved data.
Example
Data.LoadLuaTable("My_Key")
SaveNumber
function Data.SaveNumber((string)key , (number)savingNumber)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key you will use to retrieve your saved data later. |
savingNumber | number |
This is the number you're saving. |
Data.SaveNumber
Saves a number. Keep in mind that the saves will only actually get saved to file if the player goes to sleep or Data.SaveGame()
is called.
Example
Data.SaveNumber("My_Key", "Hello World")
LoadNumber
function Data.LoadNumber((string)key , (number)defaultNumber)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key to retrieve from the saved data. |
defaultNumber | number |
This is a default number that will be returned in case the key isn't found in the saved data. |
Data.LoadNumber
Loads a number from the saved data.
Example
Data.LoadNumber("My_Key", 0)
SaveBool
function Data.SaveBool((string)key , (bool)savingBool)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key you will use to retrieve your saved data later. |
savingBool | bool |
This is the bool you're saving. |
Data.SaveBool
Saves a bool. Keep in mind that the saves will only actually get saved to file if the player goes to sleep or Data.SaveGame()
is called.
Example
Data.SaveBool("My_Key", true)
LoadBool
function Data.LoadBool((string)key , (bool)defaultBool)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key to retrieve from the saved data. |
defaultBool | bool |
This is a default bool that will be returned in case the key isn't found in the saved data. |
Data.LoadBool
Loads a bool from the saved data.
Example
Data.LoadBool("My_Key", false)
HasKey
function Data.HasKey((string)key)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key to check for on the saved data. |
Data.HasKey
Checks if a key exists in the saved data. (Returns a bool)
DeleteKey
function Data.DeleteKey((string)key)
Parameter | Type | Description |
---|---|---|
key | string |
This is the key to delete from the saved data. |
Data.DeleteKey
Deletes a key from the saved data.