@@ -17,6 +17,17 @@ local function new_struct(table, struct)
17
17
return struct
18
18
end
19
19
20
+ local function arm_struct (struct )
21
+ struct .state = not struct .state
22
+ local input_itemstack = struct .state and struct .input_itemstack_1 or struct .input_itemstack_2
23
+
24
+ input_itemstack .set_stack ({name = " deconstruction-planner" , count = 1 })
25
+ storage .deathrattles [script .register_on_object_destroyed (input_itemstack .item )] = {
26
+ struct_id = struct .id ,
27
+ state = struct .state ,
28
+ }
29
+ end
30
+
20
31
function Handler .on_created_entity (event )
21
32
local entity = event .entity or event .destination -- todo: handle cloning
22
33
@@ -35,6 +46,8 @@ function Handler.on_created_entity(event)
35
46
36
47
input_itemstack_1 = nil ,
37
48
input_itemstack_2 = nil ,
49
+
50
+ state = true , -- assembling machine 1 will still be active in the tick it got placed, so we will give the item to assembling machine 2 first
38
51
})
39
52
40
53
struct .children [" assembling-machine-1" ] = storage .surface .create_entity {
@@ -82,13 +95,9 @@ function Handler.on_created_entity(event)
82
95
struct .input_itemstack_1 = struct .children [" assembling-machine-1" ].get_inventory (defines .inventory .assembling_machine_input )[1 ]
83
96
struct .input_itemstack_2 = struct .children [" assembling-machine-2" ].get_inventory (defines .inventory .assembling_machine_input )[1 ]
84
97
85
- -- assembling machine 1 will still be active in the tick it got placed, so we will give the item to assembling machine 2 first.
86
- struct .input_itemstack_2 .set_stack ({name = " deconstruction-planner" , count = 1 })
87
- storage .deathrattles [script .register_on_object_destroyed (struct .input_itemstack_2 .item )] = {
88
- struct_id = struct .id ,
89
- }
90
-
91
98
storage .next_x_offset = storage .next_x_offset + 3
99
+
100
+ arm_struct (struct )
92
101
end
93
102
94
103
for _ , event in ipairs ({
@@ -109,7 +118,7 @@ script.on_event(defines.events.on_object_destroyed, function(event)
109
118
if deathrattle then storage .deathrattles [event .registration_number ] = nil
110
119
111
120
local struct = assert (storage .greedy_inserters [deathrattle .struct_id ])
112
- game . print ( " owo " )
113
-
121
+ arm_struct ( struct )
122
+ game . print ( serpent . line ({ hand_empty = struct . state }))
114
123
end
115
124
end )
0 commit comments