mirror of
https://github.com/PHIDIAS0303/factorio-mod-PHI.git
synced 2025-12-27 11:05:22 +09:00
.
This commit is contained in:
@@ -350,63 +350,59 @@ script.on_nth_tick(1800, function(_)
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_nth_tick(10, function(_)
|
||||
local head = #storage.phi_cl.combinator.combinator_list
|
||||
local max_remove = math.floor(head / 100) + 1
|
||||
local remove_count = math.random(0, max_remove)
|
||||
local function handle_research_queue(entity)
|
||||
local combinator = entity.get_or_create_control_behavior()
|
||||
|
||||
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
|
||||
circuit_oc.add_section()
|
||||
end
|
||||
|
||||
circuit_oc = circuit_oc.sections[1]
|
||||
local cs1 = circuit_oc.get_slot(1)
|
||||
|
||||
if not (cs1 or (cs1.value and cs1.value.name and cs1.value.name == 'signal-SA')) then
|
||||
if not combinator then
|
||||
return
|
||||
end
|
||||
|
||||
local val = circuit_oc.get_slot(1).min or 0
|
||||
if combinator.sections_count and combinator.sections_count == 0 then
|
||||
combinator.add_section()
|
||||
return
|
||||
end
|
||||
|
||||
if val == 1 or val == 3 then
|
||||
local combinator_slot_1 = combinator.get_slot(1)
|
||||
|
||||
if not (combinator_slot_1 or (combinator_slot_1.value and combinator_slot_1.value.name and combinator_slot_1.value.name == 'signal-SA')) then
|
||||
combinator.add_section()
|
||||
return
|
||||
end
|
||||
|
||||
local combinator_slot_1_value = combinator_slot_1.get_slot(1).min or 0
|
||||
|
||||
if combinator_slot_1_value == 1 or combinator_slot_1_value == 3 then
|
||||
-- research_queue_read
|
||||
local n = 11
|
||||
local n = 21
|
||||
|
||||
for rn, rv in pairs(storage.phi_cl.combinator.research_queue) do
|
||||
circuit_oc.set_slot(n, {value = {type = 'virtual', name = 'signal-' .. rn, quality = 'normal'}, min = rv})
|
||||
combinator.set_slot(n, {value = {type = 'virtual', name = 'signal-' .. rn, quality = 'normal'}, min = rv})
|
||||
|
||||
n = n + 1
|
||||
end
|
||||
|
||||
for i = n, 17 do
|
||||
circuit_oc.clear_slot(i)
|
||||
for i = n, 27 do
|
||||
combinator.clear_slot(i)
|
||||
end
|
||||
|
||||
circuit_oc.set_slot(18, {value = {type = 'virtual', name = 'signal-PA', quality = 'normal'}, min = storage.phi_cl.combinator.research_progress})
|
||||
combinator.set_slot(28, {value = {type = 'virtual', name = 'signal-PA', quality = 'normal'}, min = storage.phi_cl.combinator.research_progress})
|
||||
end
|
||||
|
||||
if val == 2 or val == 3 then
|
||||
if combinator_slot_1_value == 2 or combinator_slot_1_value == 3 then
|
||||
-- research_queue_write
|
||||
|
||||
storage.phi_cl.combinator.research_set_combinator_count = storage.phi_cl.combinator.research_set_combinator_count + 1
|
||||
|
||||
if storage.phi_cl.combinator.research_set_combinator_count > 1 then
|
||||
circuit_oc.set_slot(1, {value = {type = 'virtual', name = 'signal-SA', quality = 'normal'}, min = ((val == 3) and 1) or 0})
|
||||
combinator.set_slot(1, {value = {type = 'virtual', name = 'signal-SA', quality = 'normal'}, min = ((combinator_slot_1_value == 3) and 1) or 0})
|
||||
return
|
||||
end
|
||||
|
||||
else
|
||||
local ls = cs1.get_signals(defines.wire_connector_id.circuit_red, defines.wire_connector_id.circuit_green)
|
||||
local ls = combinator.get_signals(defines.wire_connector_id.circuit_red, defines.wire_connector_id.circuit_green)
|
||||
|
||||
if not (ls or #ls < 1) then
|
||||
return
|
||||
end
|
||||
|
||||
if ls and #ls > 0 then
|
||||
for _, cs in pairs(ls) do
|
||||
local name = cs.signal.name:gsub('signal-', '')
|
||||
|
||||
@@ -439,8 +435,22 @@ script.on_nth_tick(10, function(_)
|
||||
game.forces['player'].research_queue = storage.phi_cl.combinator.research_queue_set
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
script.on_nth_tick(10, function(_)
|
||||
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
|
||||
handle_research_queue(entity)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user