Page 1 of 1

Disable death messages and respawn messages

Posted: Thu Jul 29, 2021 10:21 pm
by Honktown
Just as the title says. Any way to disable death and respawn messages completely?

Re: Disable death messages and respawn messages

Posted: Thu Jul 29, 2021 10:29 pm
by Danielv123
Came up because I needed to create a player corpse for a living player with all their items.

The solution I came up with was the following:

Code: Select all

local surface = player.surface.name
local position = player.position
local character = player.character
player.disassociate_character(character)
character.die()
player.ticks_to_respawn = nil
player.teleport(position, surface)
but that obviously creates the messages in chat. I also tried dissasociating the character from the player and then killing it etc, but no.
I also tried the following to create a corpse manually, but I couldn't figure out a way to do it.

Code: Select all

-- Manually create corpse
local corpse = surface.create_entity {
	name = "character-corpse",
	position = position,
	force = player.force,
	create_build_effect_smoke = false,
	inventory_size = 999,
	player_index = player.index,
}

for _, inv in pairs(inventories) do
	local inventory = player.get_inventory(inv)
	for i = 1, #inventory do
		local slot = inventory[i]
		if slot.valid_for_read then
			corpse.insert(slot)
		end
	end
end