Skip to content

Commit 869ff02

Browse files
committed
Cleanup entities when inserter goes away
1 parent 61461c5 commit 869ff02

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mods_2.0/053_greedy-inserter/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Version: 0.0.3
33
Date: ????
44
Info:
55
- Explode inserter when something enters the container
6+
- Cleanup entities when inserter goes away
67
---------------------------------------------------------------------------------------------------
78
Version: 0.0.2
89
Date: 2025. 01. 13

mods_2.0/053_greedy-inserter/control.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ function Handler.on_created_entity(event)
130130

131131
struct.input_itemstack_3.set_stack({name = "repair-pack", count = 2})
132132
storage.deathrattles[script.register_on_object_destroyed(struct.input_itemstack_3.item)] = {struct.id, "3"}
133+
storage.deathrattles[script.register_on_object_destroyed(entity )] = {struct.id, "3"}
133134
end
134135

135136
for _, event in ipairs({
@@ -147,7 +148,7 @@ end
147148

148149
local function purge_struct(struct)
149150
storage.greedy_inserters[struct.id] = nil
150-
struct.inserter.die()
151+
if struct.inserter.valid then struct.inserter.die() end
151152
struct.container.destroy()
152153
struct.assembler_1.destroy()
153154
struct.assembler_2.destroy()
@@ -170,7 +171,7 @@ script.on_event(defines.events.on_object_destroyed, function(event)
170171
struct.inserter.drop_target = nil
171172
end
172173
elseif deathrattle[2] == "3" then
173-
game.print("ohno")
174+
-- game.print("ohno")
174175
purge_struct(struct)
175176
else
176177
error(serpent.block(deathrattle))

0 commit comments

Comments
 (0)