I have an entity that is made up of several entities. One of them is placable, destructable and minable and controls the rest. I can place the entity or mine it just fine.
I can also destroy the master entity by e.g. shooting it. In on_entity_died I then kill the other entities as well so they turn into ghosts too. That all works. But now each entity shows the pink health bar for a destroyed entity. I want to only have one health bar for the master entity visible.
Ideas?
Entity corpses without health bar.
Re: Entity corpses without health bar.
Set the time to live of the other ghosts to max uint: https://lua-api.factorio.com/latest/Lua ... me_to_live
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Entity corpses without health bar.
Doing it before the entity.die() gives:Bilka wrote: ↑Sat Sep 14, 2019 8:36 amSet the time to live of the other ghosts to max uint: https://lua-api.factorio.com/latest/Lua ... me_to_live
Code: Select all
Error while running event LogisticTrainOrganizer::on_entity_died (ID 4)
Entity is not ghost, combat robot or highlight box entity.
Code: Select all
Error while running event LogisticTrainOrganizer::on_entity_died (ID 4)
LuaEntity API call when LuaEntity was invalid.
Re: Entity corpses without health bar.
Code: Select all
local function secondary_corpse(event, entity)
local name = entity.name
local surface = entity.surface
local pos = entity.position
entity.destructible = true
entity.die(event.force, event.cause)
ghosts = surface.find_entities_filtered{position=pos}
for _, ghost in ipairs(ghosts) do
if (ghost.name == "entity-ghost") and (ghost.ghost_name == name) then
ghost.time_to_live = 4294967295
end
end
end