This commit is contained in:
2026-05-01 21:54:42 +09:00
parent d8a6067a3f
commit 6466f04d0f
5 changed files with 116 additions and 71 deletions
+8 -54
View File
@@ -1,3 +1,6 @@
local cargo_landing_pad = require('control/cargo-landing-pad')
local cargo_landing_chest = require('control/cargo-landing-chest')
local lab = require('control/lab')
local rail_support = require('control/rail-support')
local inserter_direction = {
@@ -96,47 +99,11 @@ end
-- settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value == 'SAP'
local function entity_build(event)
cargo_landing_pad.build(event)
cargo_landing_chest.build(event)
lab.build(event)
rail_support.build(event)
if event.entity.type == 'lab' and prototypes.entity['proxy-container'] then
local p = event.entity.surface.create_entity{name = 'proxy-container', position = {event.entity.position.x, event.entity.position.y}, force = 'neutral', quality = event.entity.quality.name}
p.destructible = false
p.proxy_target_entity = event.entity
p.proxy_target_inventory = defines.inventory.lab_input
return
end
if event.entity.type == 'proxy-container' and event.entity.name == 'proxy-cargo-landing-chest' and prototypes.entity['cargo-landing-pad'] then
local ec = game.surfaces[event.entity.surface].find_entities_filtered{type='cargo-landing-pad'}
if not ec then
return
end
event.entity.proxy_target_entity = ec[1]
event.entity.proxy_target_inventory = defines.inventory.cargo_landing_pad_main
return
end
if event.entity.type == 'cargo-landing-pad' and event.entity.name == 'cargo-landing-pad' and prototypes.entity['proxy-cargo-landing-chest'] then
local ec = game.surfaces[event.entity.surface].find_entities_filtered{type='cargo-landing-pad'}
if #ec > 1 then
return
end
local ep = game.surfaces[event.entity.surface].find_entities_filtered{type='proxy-container', name='proxy-cargo-landing-chest'}
for _, v in pairs(ep) do
v.proxy_target_entity = ec[1]
v.proxy_target_inventory = defines.inventory.cargo_landing_pad_main
end
return
end
if event.entity.type == 'infinity-container' and event.entity.name == 'trash-chest' then
event.entity.remove_unfiltered_items = true
@@ -145,20 +112,6 @@ local function entity_build(event)
end
end
local function entity_destroy(event)
rail_support.destroy(event)
if event.entity.type == 'lab' and prototypes.entity['proxy-container'] then
local p = event.entity.surface.find_entity({name = 'proxy-container', force = 'neutral', quality = event.entity.quality.name}, {event.entity.position.x, event.entity.position.y})
if p then
p.destroy()
end
return
end
end
local function storage_init()
if not storage.phi_cl then
storage.phi_cl = {}
@@ -261,7 +214,8 @@ if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and set
script.on_event({defines.events.on_entity_died, defines.events.on_player_mined_entity, defines.events.on_robot_pre_mined, defines.events.script_raised_destroy}, function(event)
entity_destroy(event)
lab.destroy(event)
rail_support.destroy(event)
end)
end
+29
View File
@@ -0,0 +1,29 @@
local main = {}
function main.build(event)
if event.entity.type ~= 'cargo-landing-pad' then
return
end
if event.entity.name ~= 'cargo-landing-pad' then
return
end
if not prototypes.entity['proxy-cargo-landing-chest'] then
return
end
local ec = game.surfaces[event.entity.surface].find_entities_filtered{type='cargo-landing-pad'}
if #ec > 1 then
return
end
local ep = game.surfaces[event.entity.surface].find_entities_filtered{type='proxy-container', name='proxy-cargo-landing-chest'}
for _, v in pairs(ep) do
v.proxy_target_entity = ec[1]
v.proxy_target_inventory = defines.inventory.cargo_landing_pad_main
end
end
return main
+26
View File
@@ -0,0 +1,26 @@
local main = {}
function main.build(event)
if event.entity.type ~= 'proxy-container' then
return
end
if event.entity.name ~= 'proxy-cargo-landing-chest' then
return
end
if not prototypes.entity['cargo-landing-pad'] then
return
end
local ec = game.surfaces[event.entity.surface].find_entities_filtered{type='cargo-landing-pad'}
if not ec then
return
end
event.entity.proxy_target_entity = ec[1]
event.entity.proxy_target_inventory = defines.inventory.cargo_landing_pad_main
end
return main
+36
View File
@@ -0,0 +1,36 @@
local main = {}
function main.build(event)
if event.entity.type ~= 'lab' then
return
end
if not prototypes.entity['proxy-container'] then
return
end
local p = event.entity.surface.create_entity{name = 'proxy-container', position = {event.entity.position.x, event.entity.position.y}, force = 'neutral', quality = event.entity.quality.name}
p.destructible = false
p.proxy_target_entity = event.entity
p.proxy_target_inventory = defines.inventory.lab_input
end
function main.destroy(event)
if event.entity.type ~= 'lab' then
return
end
if not prototypes.entity['proxy-container'] then
return
end
local p = event.entity.surface.find_entity({name = 'proxy-container', force = 'neutral', quality = event.entity.quality.name}, {event.entity.position.x, event.entity.position.y})
if not p then
return
end
p.destroy()
end
return main
+8 -8
View File
@@ -6,20 +6,23 @@ local rail_support_pole = {
local main = {}
function main.build(event)
if event.entity.type == 'rail-support' then
if event.entity.type ~= 'rail-support' then
return
end
for _, v in pairs(rail_support_pole) do
if prototypes.entity[v] then
local p = event.entity.surface.create_entity{name = v, position = {event.entity.position.x, event.entity.position.y}, force = 'neutral', quality = event.entity.quality.name}
p.destructible = false
end
end
return
end
end
function main.destroy(event)
if event.entity.type == 'rail-support' then
if event.entity.type ~= 'rail-support' then
return
end
for _, v in pairs(rail_support_pole) do
if prototypes.entity[v] then
local p = event.entity.surface.find_entity({name = v, force = 'neutral', quality = event.entity.quality.name}, {event.entity.position.x, event.entity.position.y})
@@ -29,9 +32,6 @@ function main.destroy(event)
end
end
end
return
end
end
return main