Class "Mod Reference"⚓︎
Functions⚓︎
Add·Callback ()⚓︎
void AddCallback ( int callbackId, function callbackFn, int entityId )⚓︎
Has·Data ()⚓︎
boolean HasData ( )⚓︎
Returns "true" if your mod has Data stored using the "SaveData()" function. Aka. if there is a "saveX.dat" file in your mod folder. There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.
Load·Data ()⚓︎
string LoadData ( )⚓︎
Returns a string that was stored in a "saveX.dat" file using the "SaveData()" function. If there is no "saveX.dat" file in your mod, this function will return an empty string. There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.
Example Code
This code loads a string that was stored in the "saveX.dat" file, if it exists, and converts it into a table using JSON.
1 2 3 4 5 6 7 8 9 10 |
|
Remove·Callback ()⚓︎
void RemoveCallback ( int callbackId, function callbackFn )⚓︎
Remove·Data ()⚓︎
void RemoveData ( )⚓︎
Deletes the stored "saveX.dat" file if it exists. There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.
Save·Data ()⚓︎
void SaveData ( string data )⚓︎
Stores a string in a "saveX.dat" file. The stored Data persists thruout resets and game restart, so its perfect to store persistent data. There are 3 "saveX.dat" files, one per Savegame. They are stored in the mod's folder next to the "main.lua" file. The number indicates the savegame it corresponds to. The number will be determined automatically by the game.
Example Code
This code uses JSON to convert a table into a string, and saves it in the "saveX.dat" file.
1 2 3 4 5 6 7 8 9 |
|