mirror of
https://github.com/PHIDIAS0303/factorio-mod-PHI.git
synced 2026-05-12 21:08:43 +09:00
.
This commit is contained in:
+8
-54
@@ -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 rail_support = require('control/rail-support')
|
||||||
|
|
||||||
local inserter_direction = {
|
local inserter_direction = {
|
||||||
@@ -96,47 +99,11 @@ end
|
|||||||
|
|
||||||
-- settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value == 'SAP'
|
-- settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value == 'SAP'
|
||||||
local function entity_build(event)
|
local function entity_build(event)
|
||||||
|
cargo_landing_pad.build(event)
|
||||||
|
cargo_landing_chest.build(event)
|
||||||
|
lab.build(event)
|
||||||
rail_support.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
|
if event.entity.type == 'infinity-container' and event.entity.name == 'trash-chest' then
|
||||||
event.entity.remove_unfiltered_items = true
|
event.entity.remove_unfiltered_items = true
|
||||||
|
|
||||||
@@ -145,20 +112,6 @@ local function entity_build(event)
|
|||||||
end
|
end
|
||||||
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()
|
local function storage_init()
|
||||||
if not storage.phi_cl then
|
if not storage.phi_cl then
|
||||||
storage.phi_cl = {}
|
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)
|
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)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -6,31 +6,31 @@ local rail_support_pole = {
|
|||||||
local main = {}
|
local main = {}
|
||||||
|
|
||||||
function main.build(event)
|
function main.build(event)
|
||||||
if event.entity.type == 'rail-support' then
|
if event.entity.type ~= 'rail-support' then
|
||||||
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
|
return
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
function main.destroy(event)
|
function main.destroy(event)
|
||||||
if event.entity.type == 'rail-support' then
|
if event.entity.type ~= 'rail-support' then
|
||||||
for _, v in pairs(rail_support_pole) do
|
return
|
||||||
if prototypes.entity[v] then
|
end
|
||||||
local p = event.entity.surface.find_entity({name = v, force = 'neutral', quality = event.entity.quality.name}, {event.entity.position.x, event.entity.position.y})
|
|
||||||
|
|
||||||
if p then
|
for _, v in pairs(rail_support_pole) do
|
||||||
p.destroy()
|
if prototypes.entity[v] then
|
||||||
end
|
local p = event.entity.surface.find_entity({name = v, force = 'neutral', quality = event.entity.quality.name}, {event.entity.position.x, event.entity.position.y})
|
||||||
|
|
||||||
|
if p then
|
||||||
|
p.destroy()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user