FrogDataLib
A straightforward library for managing mod save data
About this mod Author’s original text
🐸 FrogDataLib for YAPYAP
FrogDataLib is a lightweight data persistence framework for YAPYAP mods. It allows developers to save and load custom mod data into "sidecar" files, preventing save game pollution and ensuring mod data stays synchronized with the user's active save slot.
Features
- Zero Pollution: Mod data is stored in %AppData%/LocalLow/maisonbap/YAPYAP/FrogData, keeping vanilla saves clean.
- Slot Synchronization: Automatically handles saving, loading, and deleting data based on the user's active save slot.
- Type Safety: Uses a generic FrogDataContainer pattern for easy serialization.
- Corrupt-Data Protection: Includes a "Sentinel" check to detect failed Unity JSON deserialization.
- Two-Tier Deserialization: Internally stores mod saves as strings and serializes them just in time to avoid TypeLoadExceptions when mods are modified on an active save (not recommended!)
For Developers: How to Use
See the full Example Project for more in-depth usage tips!
Define your Data Model
Your data class must inherit from FrogDataModel and be marked with the [Serializable] attribute.
using FrogDataLib.DataManagement;
using System;
[Serializable]
public class MyModData: FrogDataModel
{
public int PlayerKills;
public string FavoriteFrogName;
}
Initialize the Container
Create a container using a unique GUID (usually your mod's ID).
private FrogDataContainer _dataContainer;
void Awake()
{
_dataContainer = new FrogDataContainer("com.yourname.mymod");
// Subscribe to FrogDataLib events
FrogDataManager.OnBeginSaving += SaveMyData;
FrogDataManager.OnLoadCompleted += LoadMyData;
}
Use Your Object Like Normal
myData.FavoriteFrogName = "Gertrude";
Saving and Loading
Use the provided events to stay in sync with the game session.
// Called when the user clicks "Save" in-game
private void SaveMyData() =>
_dataContainer.SaveModData(myData);
// Called when a save slot is finished loading
private void LoadMyData()
{
MyModData data = _dataContainer.GetModData();
Debug.Log($"Loaded: {data.FavoriteFrogName}");
}
Important Notes
- The Frog Sentinel: FrogDataLib uses an internal integer (8675309) to verify that Unity's JsonUtility didn't silently fail. If your model isn't marked [Serializable], the sentinel will be 0, and the frogs will refuse to save/load to prevent data loss.
- Session Cleanup: Use the OnSessionEnded event to clear your local variables when a user returns to the Main Menu.
Install & use Install: follow the bundled instructions
- Unzip the archive from playbuff and read the bundled readme / instructions first.
- Most mods rely on the game's mod loader — the usual route is a community mod manager (such as r2modman): pick this game, install, and it handles the loader and dependencies.
- For a manual install, put the mod files into the matching Mod / plugins folder inside the game directory.
- Launch the game to confirm it loaded; mods with listed dependencies need those installed as well.
Install locations vary a lot between mods — the bundled readme is the most reliable guide.
Install these first, or the mod will not work: