Page 1 of 1

No ghost on entity death

Posted: Sun Jan 22, 2017 1:46 pm
by Sirenfal
Is there a way to specify that I do not want an automatic ghost for a particular entity when it dies?

I can do that with a hook like this, but it's not exactly clean-

Code: Select all

script.on_event(defines.events.on_entity_died, function(event)
	if(event.entity.name == 'my_entity') then
		local ent = event.entity
		local surface = ent.surface
		local pos = ent.position
		local corpse = ent.prototype.corpses

		ent.destroy()

		-- this isn't available to prototype information at runtime
		surface.create_entity({
			name='medium-explosion',
			position=pos,
		})

		for corpse_name, _ in pairs(corpse) do
			surface.create_entity({
				name=corpse_name,
				position=pos,
			})
		end

		return
	end
end)

Re: No ghost on entity death

Posted: Wed Feb 01, 2017 11:24 pm
by aubergine18
IIRC there's a "not-repairable" flag you can define on entity prototypes - if false, ghosts don't appear on destroy.