Files
factorio-clusterio/plugins/player_sync/README.md
T
bbassieandClaude Opus 5.5 8363c5f0ef Rename inventory_sync to player_sync
The plugin syncs more than inventories now (settings, appearance, recipe
notifications), so name it for what it does. The package becomes
@clusterio/plugin-player_sync and every inventory_sync identifier follows.

A migration entrypoint renames the inventory_sync config fields, including
load_plugin, and the inventory view permission. The plugin moves
inventories.json in the database directory to player_sync.json and
storage.inventory_sync in saves to storage.player_sync itself, and closes
dialogs left open under the old GUI names on startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 16:37:12 +00:00

4.6 KiB

Clusterio player sync plugin

Carry over player inventories and settings between servers

As a player, it mostly just works. Most important to know is that factorio data transfer is slow, which means if you have "big" items (blueprints mostly) in your inventory it will take a long time to transfer when joining servers. For this reason it is recommended to keep blueprints in the blueprint library.

A note on crashing servers:

When a server crashes while you are online there won't be time to immediately upload the inventory. Instead, the inventory is uploaded as soon as the server restarts. This means if you have been playing on a different server from the one that crashed and gathered/consumed items but are offline at the time of the first server coming online again your inventory will reset to the autosave.

Installation

Run the following commands in the folder Clusterio is installed to:

npm install @clusterio/plugin-player_sync
npx clusteriocontroller plugin add @clusterio/plugin-player_sync

Substitute clusteriocontroller with clusteriohost or clusterioctl if this a dedicated host or ctl installation respectively.

Upgrading from inventory_sync

This plugin was called inventory_sync before 2.0.0-alpha.28. Remove the old package and install the new one in its place:

npm uninstall @clusterio/plugin-inventory_sync
npm install @clusterio/plugin-player_sync
npx clusteriocontroller plugin remove inventory_sync
npx clusteriocontroller plugin add @clusterio/plugin-player_sync

The inventory_sync.* config fields and the inventory_sync.inventory.view permission are renamed on load. The controller moves inventories.json in the database directory to player_sync.json, and saves keep their player data the next time they are started with the new module.

Method of operation

This plugin does event based synchronization of inventories. The greatly simplified data flow is as follows:

  1. Player joins server.

  2. Scenario script asks controller for exclusive access to the player.

  3. Controller grants exclusive access for the player to the instance.

  4. Scenario script checks the access response and then acts according to the situation:

    1. If the player has no inventory on the controller then the current inventory becomes the synced inventory and the process is done.
    2. If the player inventory was previously uploaded and is the same as the one stored on the controller then the current inventory becomes the synced inventory and the process is done.
    3. If the player inventory was previously uploaded but is not the same then the player inventory is deleted and the player is turned into a spectator.
    4. Otherwise the player inventory is kept.
  5. Scenario script asks for the player inventory from the controller, including its current recipe notification state.

  6. Controller sends it to the scenario in a stream of chunks, with only the recipe notifications that differ from the current state.

  7. Scenario displays and updates a progress bar as each chunk is received.

  8. Once all chunks have loaded the player's synced inventory is recreated from the data and the player can start playing.

When the player leaves the inventory is uploaded if it's a synced inventory and the exclusive access the scenario script holds is released. Should an error occur during this process the player is given the option to use a temporary inventory instead, which will be merged back into the synced inventory the next time the sync succeeds on that instance.

Communication between the server and instance goes over stdout or rcon, depending on the size of the data. Communication between the instance and the controller goes over websockets. Overall, we are able to achieve a latency between 3 and infinite ticks from server join, depending on the size of the inventory. The major limiter is rcon transfer speeds with larger inventories, especially if they contain blueprints.

Controller Configuration

player_sync.player_lock_timeout

Time in seconds before the exclusive access an instance holds on a player's inventory expires after the instance stops or its host disconnects. Until it expires the player is told the inventory is in use on that instance when joining another one. The timeout is cancelled if the instance comes back before it runs out.

Defaults to 60.

Instance Configuration

player_sync.rcon_chunk_size

Size in characters of the chunks the serialized inventory is split into when sent to the game over RCON. Smaller chunks take more commands to transfer an inventory but hold up the RCON command pipe for less time each.

Defaults to 1000.