Offer the player a temporary inventory while waiting for master

This commit is contained in:
Daniel committed 2021-07-29 23:55:48 +02:00
1 parent 29917fb85a
commit e63f1246da
8 files changed
+172 -2

No files matched your search

@@ -0,0 +1,29 @@
local inventories = require("modules/inventory_sync/define_player_inventories")
--[[
Take a player with a dirty inventory, create chests with all the items, clear the player,
put them in ghost mode and mark the inventory as clean.
]]
function clean_dirty_inventory(player)
global.inventory_sync.players[player.name].dirty_inventory = false
local surface = player.surface
local position = player.position
local character = player.character
player.disassociate_character(character)
character.die()
player.ticks_to_respawn = nil
player.teleport(position, surface)
-- Remove player character
local character = player.character
player.set_controller {
type = defines.controllers.ghost,
}
if character ~= nil then character.destroy() end
end
return clean_dirty_inventory