mirror of
https://github.com/PHIDIAS0303/factorio-mod-PHI.git
synced 2025-12-27 11:05:22 +09:00
.
This commit is contained in:
@@ -178,15 +178,29 @@ script.on_init(function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
storage.phi_cl = {
|
if not storage.phi_cl then
|
||||||
cargo_landing_pad_storage = {},
|
storage.phi_cl = {}
|
||||||
combinator = {
|
end
|
||||||
|
|
||||||
|
if not storage.phi_cl.loop then
|
||||||
|
storage.phi_cl.loop = {
|
||||||
|
cargo_landing_pad_storage = false,
|
||||||
|
combinator = false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
if not storage.phi_cl.cargo_landing_pad_storage then
|
||||||
|
storage.phi_cl.cargo_landing_pad_storage = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
if not storage.phi_cl.combinator then
|
||||||
|
storage.phi_cl.combinator = {
|
||||||
research_set_combinator_count = 0,
|
research_set_combinator_count = 0,
|
||||||
research_queue = {},
|
research_queue = {},
|
||||||
research_queue_set = {},
|
research_queue_set = {},
|
||||||
research_progress = 0
|
research_progress = 0
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_configuration_changed(function()
|
script.on_configuration_changed(function()
|
||||||
@@ -200,7 +214,17 @@ script.on_configuration_changed(function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if storage.phi_cl then
|
if not storage.phi_cl then
|
||||||
|
storage.phi_cl = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
if not storage.phi_cl.loop then
|
||||||
|
storage.phi_cl.loop = {
|
||||||
|
cargo_landing_pad_storage = false,
|
||||||
|
combinator = false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
if not storage.phi_cl.cargo_landing_pad_storage then
|
if not storage.phi_cl.cargo_landing_pad_storage then
|
||||||
storage.phi_cl.cargo_landing_pad_storage = {}
|
storage.phi_cl.cargo_landing_pad_storage = {}
|
||||||
end
|
end
|
||||||
@@ -213,58 +237,11 @@ script.on_configuration_changed(function()
|
|||||||
research_progress = 0
|
research_progress = 0
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
storage.phi_cl.loop.cargo_landing_pad_storage = (settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value == 'VP')
|
||||||
|
storage.phi_cl.loop.combinator = (settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value ~= ''))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value == 'VP' then
|
|
||||||
script.on_nth_tick(1800, function(_)
|
|
||||||
--
|
|
||||||
local ec = game.surfaces[1].find_entities_filtered{type='cargo-landing-pad'}
|
|
||||||
local ec_count = #ec
|
|
||||||
|
|
||||||
if ec_count <= 1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local inv = ec[1].get_inventory(defines.inventory.cargo_landing_pad_main)
|
|
||||||
|
|
||||||
if inv then
|
|
||||||
local item = inv.get_contents()
|
|
||||||
|
|
||||||
for _, v in pairs(item) do
|
|
||||||
if storage.phi_cl.cargo_landing_pad_storage[v.name] and (storage.phi_cl.cargo_landing_pad_storage[v.name].quality == v.quality) then
|
|
||||||
storage.phi_cl.cargo_landing_pad_storage[v.name][v.quality] = storage.phi_cl.cargo_landing_pad_storage[v.name] + v.count
|
|
||||||
|
|
||||||
else
|
|
||||||
storage.phi_cl.cargo_landing_pad_storage[v.name] = {[v.quality] = v.count}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
inv.clear()
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, e in pairs(ec) do
|
|
||||||
local inventory = e.get_inventory(defines.inventory.chest)
|
|
||||||
local inventory_request_sections = e.get_logistic_sections().sections
|
|
||||||
|
|
||||||
if inventory then
|
|
||||||
for i = 1, #inventory_request_sections do
|
|
||||||
for _, v in pairs(inventory_request_sections[i].filters) do
|
|
||||||
if v.value and v.value.quality then
|
|
||||||
local request_amount = math.min(v.min - inventory.get_item_count(v.value.name), storage.phi_cl.cargo_landing_pad_storage[v.value.name][v.value.quality])
|
|
||||||
|
|
||||||
if request_amount > 0 and inventory.can_insert{name = v.value.name, count = request_amount, quality = v.value.quality} then
|
|
||||||
storage.phi_cl.cargo_landing_pad_storage[v.value.name][v.value.quality] = storage.phi_cl.cargo_landing_pad_storage[v.value.name][v.value.quality] - request_amount
|
|
||||||
inventory.insert{name = v.value.name, count = request_amount, quality = v.value.quality}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value ~= '') then
|
if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and settings.startup['PHI-GM'].value ~= '') then
|
||||||
script.on_event(defines.events.on_player_created, function(event)
|
script.on_event(defines.events.on_player_created, function(event)
|
||||||
gui_create(game.players[event.player_index])
|
gui_create(game.players[event.player_index])
|
||||||
@@ -319,7 +296,62 @@ if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and set
|
|||||||
entity_destroy(event)
|
entity_destroy(event)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings.startup['PHI-CT'].value then
|
||||||
|
script.on_event({defines.events.on_player_cheat_mode_enabled, defines.events.on_player_cheat_mode_disabled}, function(event)
|
||||||
|
hidden_recipe_enable(event)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
script.on_nth_tick(1800, function(_)
|
script.on_nth_tick(1800, function(_)
|
||||||
|
if storage.phi_cl.loop.cargo_landing_pad_storage then
|
||||||
|
local ec = game.surfaces[1].find_entities_filtered{type='cargo-landing-pad'}
|
||||||
|
local ec_count = #ec
|
||||||
|
|
||||||
|
if ec_count <= 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local inv = ec[1].get_inventory(defines.inventory.cargo_landing_pad_main)
|
||||||
|
|
||||||
|
if inv then
|
||||||
|
local item = inv.get_contents()
|
||||||
|
|
||||||
|
for _, v in pairs(item) do
|
||||||
|
if storage.phi_cl.cargo_landing_pad_storage[v.name] and (storage.phi_cl.cargo_landing_pad_storage[v.name].quality == v.quality) then
|
||||||
|
storage.phi_cl.cargo_landing_pad_storage[v.name][v.quality] = storage.phi_cl.cargo_landing_pad_storage[v.name][v.quality] + v.count
|
||||||
|
|
||||||
|
else
|
||||||
|
storage.phi_cl.cargo_landing_pad_storage[v.name] = {[v.quality] = v.count}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
inv.clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, e in pairs(ec) do
|
||||||
|
local inventory = e.get_inventory(defines.inventory.chest)
|
||||||
|
local inventory_request_sections = e.get_logistic_sections().sections
|
||||||
|
|
||||||
|
if inventory then
|
||||||
|
for i = 1, #inventory_request_sections do
|
||||||
|
for _, v in pairs(inventory_request_sections[i].filters) do
|
||||||
|
if v.value and v.value.quality then
|
||||||
|
local request_amount = math.min(v.min - inventory.get_item_count(v.value.name), storage.phi_cl.cargo_landing_pad_storage[v.value.name][v.value.quality])
|
||||||
|
|
||||||
|
if request_amount > 0 and inventory.can_insert{name = v.value.name, count = request_amount, quality = v.value.quality} then
|
||||||
|
storage.phi_cl.cargo_landing_pad_storage[v.value.name][v.value.quality] = storage.phi_cl.cargo_landing_pad_storage[v.value.name][v.value.quality] - request_amount
|
||||||
|
inventory.insert{name = v.value.name, count = request_amount, quality = v.value.quality}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if storage.phi_cl.loop.combinator then
|
||||||
storage.phi_cl.combinator.research_progress = math.floor(game.forces['player'].research_progress * 100)
|
storage.phi_cl.combinator.research_progress = math.floor(game.forces['player'].research_progress * 100)
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -410,11 +442,5 @@ if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and set
|
|||||||
-- game.forces['player'].research_queue = storage.phi_cl.combinator.research_queue_set
|
-- game.forces['player'].research_queue = storage.phi_cl.combinator.research_queue_set
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if settings.startup['PHI-CT'].value then
|
|
||||||
script.on_event({defines.events.on_player_cheat_mode_enabled, defines.events.on_player_cheat_mode_disabled}, function(event)
|
|
||||||
hidden_recipe_enable(event)
|
|
||||||
end)
|
end)
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user