Skip to content

Commit 5d95bc7

Browse files
committed
Poorly assign item request proxies as proof of concept
1 parent d76f111 commit 5d95bc7

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

mods/se-interstellar-construction-requests-fulfillment/control.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ script.on_nth_tick(600, function(event)
3737

3838
for surface_index, surface_alerts in pairs(alerts) do
3939
for _, surface_alert in ipairs(surface_alerts[defines.alert_type.no_material_for_construction]) do
40+
Handler.handle_construction_alert(surface_alert)
4041
-- {
4142
-- {
4243
-- count = 1,
@@ -50,7 +51,6 @@ script.on_nth_tick(600, function(event)
5051
-- name = "storage-tank"
5152
-- }
5253
-- }
53-
log(serpent.block(surface_alert.target.ghost_prototype.items_to_place_this))
5454
end
5555
end
5656
end

mods/se-interstellar-construction-requests-fulfillment/data.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ local item = {
7373
order = 'k-a', -- weapon delivery cannon is `j-`
7474
subgroup = 'surface-defense',
7575
stack_size = 50,
76+
flags = {'draw-logistic-overlay'},
7677
}
7778

7879
item.place_result = turret.name

mods/se-interstellar-construction-requests-fulfillment/info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "se-interstellar-construction-requests-fulfillment",
33
"title": "Space Exploration - interstellar construction requests fulfillment",
44
"description": "Keeping building equipment stocked at every planet is tedious, just shoot it there from nauvis.",
5-
"version": "0.0.14",
5+
"version": "0.0.15",
66
"author": "Quezler",
77
"factorio_version": "1.1",
88
"dependencies": [

mods/se-interstellar-construction-requests-fulfillment/scripts/handler.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,37 @@ function Handler.tick(event)
4141
end
4242
end
4343

44+
function Handler.handle_construction_alert(alert)
45+
if alert.target.name ~= "entity-ghost" then return end -- can be "item-request-proxy"
46+
log(alert.target.unit_number)
47+
48+
-- game.print(serpent.block(alert.target.ghost_prototype.items_to_place_this))
49+
for _, item_to_place_this in ipairs(alert.target.ghost_prototype.items_to_place_this) do
50+
if item_to_place_this.count == 1 then
51+
game.print(item_to_place_this.name)
52+
53+
for unit_number, struct in pairs(global.structs) do
54+
if not struct.entity.valid then
55+
global.structs[unit_number] = nil
56+
else
57+
if alert.target.force == struct.entity.force then
58+
-- we're gonna check for orange coverage for now, instead of green venn diagrams and filtering out personal roboports
59+
local network = struct.entity.surface.find_logistic_network_by_position(struct.entity.position, struct.entity.force)
60+
if network then
61+
struct.entity.surface.create_entity{
62+
name = 'item-request-proxy',
63+
force = struct.entity.force,
64+
target = struct.entity,
65+
position = {0,0},
66+
modules = {[item_to_place_this.name] = item_to_place_this.count}
67+
}
68+
end
69+
end
70+
end
71+
end
72+
end
73+
end
74+
75+
end
76+
4477
return Handler

0 commit comments

Comments
 (0)