Files
factorio-clusterio/plugins/player_sync/module/get_script_data.lua
T
ILLISISandClaude Opus 5.5 b32f5416a1 Keep main inventory slots from armor equipment when restoring a character
The inventory bonus of equipment in the armor's grid (toolbelts) is
applied by the engine on the tick after the armor is inserted. The main
inventory was restored in the same tick, so the items of every slot past
80 plus research plus the armor's own bonus did not fit and were put in
a corpse: legendary mech armor with legendary toolbelts left 2125 of
2330 slots in the corpse.

The armor is now restored first, the character's inventory bonus is
raised to fit the saved main inventory, and the raise is removed again
on the next tick, or before an upload if the player leaves first.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-18 22:34:05 +11:00

30 lines
1.2 KiB
Lua

local compat = require("modules/clusterio/compat")
--- @param no_early_return boolean? True to always setup data
return function(no_early_return)
local player_sync = compat.script_data.player_sync
if player_sync and not no_early_return then
return player_sync
end
-- migrate: inventory_sync was renamed to player_sync in 2.0.0-alpha.28
if not player_sync and compat.script_data.inventory_sync then
player_sync = compat.script_data.inventory_sync
compat.script_data.inventory_sync = nil
end
player_sync = player_sync or {}
player_sync.players = player_sync.players or {}
player_sync.players_waiting_for_acquire = player_sync.players_waiting_for_acquire or {}
player_sync.players_in_cutscene_to_sync = player_sync.players_in_cutscene_to_sync or {}
player_sync.failed_deserialization = player_sync.failed_deserialization or {}
player_sync.inventory_bonus_raises = player_sync.inventory_bonus_raises or {}
player_sync.active_downloads = player_sync.active_downloads or {}
player_sync.finished_downloads = player_sync.finished_downloads or {}
player_sync.active_uploads = player_sync.active_uploads or {}
compat.script_data.player_sync = player_sync
return player_sync
end