mirror of
https://github.com/PHIDIAS0303/factorio-mod-PHI.git
synced 2025-12-27 11:05:22 +09:00
.
This commit is contained in:
@@ -219,6 +219,8 @@ local function storage_init()
|
|||||||
if not storage.phi_cl.combinator then
|
if not storage.phi_cl.combinator then
|
||||||
storage.phi_cl.combinator = {
|
storage.phi_cl.combinator = {
|
||||||
research_set_combinator_count = 0,
|
research_set_combinator_count = 0,
|
||||||
|
combinator_list = {},
|
||||||
|
combinator_list_len = 0,
|
||||||
research_queue = {},
|
research_queue = {},
|
||||||
research_queue_set = {},
|
research_queue_set = {},
|
||||||
research_progress = 0
|
research_progress = 0
|
||||||
@@ -322,8 +324,8 @@ end
|
|||||||
script.on_nth_tick(1800, function(_)
|
script.on_nth_tick(1800, function(_)
|
||||||
if storage.phi_cl.loop.combinator then
|
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)
|
||||||
|
storage.phi_cl.combinator.combinator_list = {}
|
||||||
do
|
storage.phi_cl.combinator.combinator_list_len = 0
|
||||||
storage.phi_cl.combinator.research_queue = {}
|
storage.phi_cl.combinator.research_queue = {}
|
||||||
storage.phi_cl.combinator.research_queue_set = {
|
storage.phi_cl.combinator.research_queue_set = {
|
||||||
[1] = nil,
|
[1] = nil,
|
||||||
@@ -346,7 +348,6 @@ script.on_nth_tick(1800, function(_)
|
|||||||
|
|
||||||
n = n + 1
|
n = n + 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
for _, s in pairs(game.surfaces) do
|
for _, s in pairs(game.surfaces) do
|
||||||
local c = s.find_entities_filtered{type='constant-combinator', name='super-combinator'}
|
local c = s.find_entities_filtered{type='constant-combinator', name='super-combinator'}
|
||||||
@@ -355,8 +356,26 @@ script.on_nth_tick(1800, function(_)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, sc in pairs(c) do
|
storage.phi_cl.combinator.combinator_list = c
|
||||||
local circuit_oc = sc.get_or_create_control_behavior()
|
storage.phi_cl.combinator.combinator_list_len = math.ceil(#c / 175)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
script.on_nth_tick(10, function(event)
|
||||||
|
local head = #storage.phi_cl.combinator.combinator_list
|
||||||
|
local max_remove = math.floor(head / 100) + 1
|
||||||
|
local remove_count = math.random(0, max_remove)
|
||||||
|
|
||||||
|
while remove_count > 0 and head > 0 do
|
||||||
|
local remove_index = math.random(1, head)
|
||||||
|
local entity = storage.phi_cl.combinator.combinator_list[remove_index]
|
||||||
|
storage.phi_cl.combinator.combinator_list[remove_index] = storage.phi_cl.combinator.combinator_list[head]
|
||||||
|
head = head - 1
|
||||||
|
|
||||||
|
if entity and entity.valid then
|
||||||
|
remove_count = remove_count - 1
|
||||||
|
local circuit_oc = entity.get_or_create_control_behavior()
|
||||||
|
|
||||||
if circuit_oc and circuit_oc.sections_count and circuit_oc.sections_count == 0 then
|
if circuit_oc and circuit_oc.sections_count and circuit_oc.sections_count == 0 then
|
||||||
circuit_oc.add_section()
|
circuit_oc.add_section()
|
||||||
@@ -415,7 +434,6 @@ script.on_nth_tick(1800, function(_)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
end
|
|
||||||
|
|
||||||
-- 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
|
||||||
|
|||||||
Reference in New Issue
Block a user