Class "Mod Reference"⚓︎
Functions⚓︎
Add·Callback ()⚓︎
void AddCallback ( ModCallbacks callbackId, function callbackFn, int entityId )⚓︎
Add·Priority·Callback ()⚓︎
void AddPriorityCallback ( ModCallbacks callbackId, CallbackPriority priority, function callbackFn, int entityId )⚓︎
Allows modders to specify that a callback function should run earlier or later than normal relative to other functions added to that callback.
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 between runs and between game launches.
- The filename will be either "save1.dat", "save2.dat", or "save3.dat", depending on which save file slot the user is playing on.
- The file will be located in the "data" directory. For example:
C:\Program Files (x86)\Steam\steamapps\common\The Binding of Isaac Rebirth\data\foo\save1.dat
- Since mods will often have to store more than a single variable, it is recommended to store all persistent variables for your mod in a Lua table, and then convert the table to a JSON string before using this function.
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 10 11 12 13 14 15 |
|
- Note that for security reasons, the game only allows you to write data to these three files. If you want to write data to arbitrary files, you have to use the
--luadebug
flag, which will enable the Lua standard library.