Skip to content

Storage and save recovery ​

Use mod.Persistence for typed mod data. Global is local to the installation and commits immediately. World and entity scopes are owned by the host or single-player game and commit with the next native save. Persistence reference

Store world data ​

Register this listener during OnInitializeMelon. On the authority peer it records how often the mod has opened the world. It can be added to the first mod.

csharp
mod.Events.World.Loaded.Subscribe("count_world_loads", _ =>
{
    if (!mod.Persistence.IsWorldAuthority)
    {
        return;
    }

    mod.Persistence.World.Batch(data =>
    {
        int opens = data.Get("open_count", 0);
        data.Set("open_count", opens + 1);
    });
});

Use ForPart(part) when data follows a placed part, or mark component properties with [Persist] for component state. Use persistent GUIDs for ship, part, and player scopes. Reacquire scoped storage after opening a different world. A batch applies changes to one scope together when its synchronous callback succeeds.

Evolve stored data ​

Declare the storage schema with DefineSchema(version) during initialisation. Register one RegisterMigration(fromVersion, action) per transition before accessing global data or opening a world. A migration receives StorageMigration and can update keys in existing scopes through For. The same schema applies to global and world data, so use IsGlobal to select applicable work. Component state has its own ComponentOptions.SchemaVersion and UpgradeState.

Upgrade an installation ​

Keep matching releases of StellarWorks and shared content on every multiplayer peer. An existing StellarStriderLib world requires the original framework and compatible mods. StellarWorks detects its sidecars and preserves them. Start a separate StellarWorks world when porting an SSLib mod.

For earlier StellarWorks installs, switch to the bundled DLL. Worlds containing removed parts or processor and managed inventory components from StellarWorks 0.9.0 need their original installation. Worlds containing parts from the former Workshop example still require that add-on.

Recover a world ​

Back up the world directory with the game closed. A StellarWorks world contains the native save and StellarWorks/world.db in the same world directory. Verified pairs live under StellarWorks/Backups/Pairs/<generation>/. StellarWorks can recover a missing matching database generation from a valid backup.

To recover a damaged save or database manually:

  1. Close the game and preserve copies of the current files.
  2. Choose a single backup generation. Copy its native.json back into the world directory under the original native save filename.
  3. Restore that generation's world.db to StellarWorks/world.db within the same world directory.
  4. Launch the game with the mods that own the saved content and open the restored world.

StellarWorks documentation · Mods for StellarDrive