LuaEntity.unrevive() turn an entity into a ghost

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

LuaEntity.unrevive() turn an entity into a ghost

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 525
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

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

Post 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
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Modding interface requests”