Page 1 of 1

LuaEntity.unrevive() turn an entity into a ghost

Posted: Fri Oct 23, 2020 3:48 pm
by eradicator
What

Any method to do the opposite of LuaEntity.revive(). Possibly as an extra argument to LuaEntity.destroy()?

Why?

Because LuaEntity.die() has several undesired side-effects: It makes noise, it creates remnants and it *doesn't* even create a ghost if the force doesn't have construction robotics yet.

Re: LuaEntity.unrevive() turn an entity into a ghost

Posted: Sat Oct 24, 2020 1:40 pm
by Mylon
You can manually change the force's ghost_time_to_live to be a positive number to force a ghost to spawn on entity death.

Code: Select all

local force = entity.force
	local ttl = force.ghost_time_to_live
        force.ghost_time_to_live = 60 * 60 * 60 --1 hour
        entity.die()
        force.ghost_time_to_live = ttl

Re: LuaEntity.unrevive() turn an entity into a ghost

Posted: Sat Oct 24, 2020 2:55 pm
by eradicator
Yea, and if the remnants are decoratives i could probably deal with those too. But that makes a rather ugly+complicated hack that still makes an ugly death noise - for something that should be simple.