File tree Expand file tree Collapse file tree 3 files changed +15
-24
lines changed
mods/se-cargo-rocket-construction-helper Expand file tree Collapse file tree 3 files changed +15
-24
lines changed Original file line number Diff line number Diff line change 27
27
28
28
--
29
29
30
- local events = {
31
- [defines .events .on_built_entity ] = silo .on_created_entity ,
32
- [defines .events .on_robot_built_entity ] = silo .on_created_entity ,
33
- [defines .events .script_raised_built ] = silo .on_created_entity ,
34
- [defines .events .script_raised_revive ] = silo .on_created_entity ,
35
- [defines .events .on_entity_cloned ] = silo .on_created_entity ,
36
- }
37
-
38
- for event , handler in pairs (events ) do
39
- script .on_event (event , handler )
30
+ for _ , event in ipairs ({
31
+ defines .events .on_built_entity ,
32
+ defines .events .on_robot_built_entity ,
33
+ defines .events .script_raised_built ,
34
+ defines .events .script_raised_revive ,
35
+ }) do
36
+ script .on_event (event , silo .on_created_entity , {
37
+ {filter = ' name' , name = ' se-rocket-launch-pad' },
38
+ })
40
39
end
41
40
41
+
42
42
script .on_nth_tick (60 * 10 , function ()
43
43
silo .every_10_seconds ()
44
44
end )
Original file line number Diff line number Diff line change 2
2
"name" : " se-cargo-rocket-construction-helper" ,
3
3
"title" : " Space Exploration - cargo rocket construction helper" ,
4
4
"description" : " Delivers the capsule and rocket parts to the silo with construction robots." ,
5
- "version" : " 1.0.11 " ,
5
+ "version" : " 1.0.12 " ,
6
6
"author" : " Quezler" ,
7
7
"factorio_version" : " 1.1" ,
8
8
"dependencies" : [
Original file line number Diff line number Diff line change @@ -11,20 +11,9 @@ function silo.init()
11
11
12
12
end
13
13
14
- function silo .is_valid_cargo_rocket_silo (entity )
15
- if not entity then return false end
16
- if not entity .valid then return false end
17
- if entity .type ~= " container" then return false end
18
- if entity .name ~= " se-rocket-launch-pad" then return false end
19
-
20
- return true
21
- end
22
-
23
14
function silo .on_created_entity (event )
24
15
local entity = event .created_entity or event .entity or event .destination
25
- if not silo .is_valid_cargo_rocket_silo (entity ) then return end
26
16
27
- -- game.print(entity.name)
28
17
silo .register (entity )
29
18
end
30
19
@@ -65,8 +54,10 @@ function silo.random_tick(entry)
65
54
66
55
--
67
56
68
- local missing_sections = 100 - entry .combinator .get_or_create_control_behavior ().get_signal (2 ).count -- todo: - any sections still in the container
69
- local missing_capsules = 1 - entry .combinator .get_or_create_control_behavior ().get_signal (3 ).count -- todo: - any capsules still in the container
57
+ local container_inventory = entry .container .get_inventory (defines .inventory .chest )
58
+
59
+ local missing_sections = 100 - entry .combinator .get_or_create_control_behavior ().get_signal (2 ).count - container_inventory .get_item_count (' se-cargo-rocket-section' )
60
+ local missing_capsules = 1 - entry .combinator .get_or_create_control_behavior ().get_signal (3 ).count - container_inventory .get_item_count (' se-space-capsule' )
70
61
71
62
if missing_sections > 0 or missing_capsules > 0 then
72
63
You can’t perform that action at this time.
0 commit comments