Disable death messages and respawn messages

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Disable death messages and respawn messages

Post by Honktown »

Just as the title says. Any way to disable death and respawn messages completely?
I have mods! I guess!
Link

Danielv123
Inserter
Inserter
Posts: 48
Joined: Sun Jan 03, 2016 10:28 am
Contact:

Re: Disable death messages and respawn messages

Post 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

Post Reply

Return to “Gameplay Help”