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,30 +324,29 @@ 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 = {}
|
||||||
|
storage.phi_cl.combinator.combinator_list_len = 0
|
||||||
|
storage.phi_cl.combinator.research_queue = {}
|
||||||
|
storage.phi_cl.combinator.research_queue_set = {
|
||||||
|
[1] = nil,
|
||||||
|
[2] = nil,
|
||||||
|
[3] = nil,
|
||||||
|
[4] = nil,
|
||||||
|
[5] = nil,
|
||||||
|
[6] = nil,
|
||||||
|
[7] = nil
|
||||||
|
}
|
||||||
|
storage.phi_cl.combinator.research_set_combinator_count = 0
|
||||||
|
local n = 1
|
||||||
|
|
||||||
do
|
for _, r in pairs(game.forces['player'].research_queue) do
|
||||||
storage.phi_cl.combinator.research_queue = {}
|
local raw_name = r.name:gsub('-%d+$', '')
|
||||||
storage.phi_cl.combinator.research_queue_set = {
|
|
||||||
[1] = nil,
|
|
||||||
[2] = nil,
|
|
||||||
[3] = nil,
|
|
||||||
[4] = nil,
|
|
||||||
[5] = nil,
|
|
||||||
[6] = nil,
|
|
||||||
[7] = nil
|
|
||||||
}
|
|
||||||
storage.phi_cl.combinator.research_set_combinator_count = 0
|
|
||||||
local n = 1
|
|
||||||
|
|
||||||
for _, r in pairs(game.forces['player'].research_queue) do
|
if r.name and r.level and r.research_unit_count_formula then
|
||||||
local raw_name = r.name:gsub('-%d+$', '')
|
storage.phi_cl.combinator.research_queue[raw_name] = ((storage.phi_cl.combinator.research_queue[raw_name] and storage.phi_cl.combinator.research_queue[raw_name]) or 0) + math.pow(2, n - 1)
|
||||||
|
|
||||||
if r.name and r.level and r.research_unit_count_formula then
|
|
||||||
storage.phi_cl.combinator.research_queue[raw_name] = ((storage.phi_cl.combinator.research_queue[raw_name] and storage.phi_cl.combinator.research_queue[raw_name]) or 0) + math.pow(2, n - 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
n = n + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
n = n + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, s in pairs(game.surfaces) do
|
for _, s in pairs(game.surfaces) do
|
||||||
@@ -355,40 +356,58 @@ 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)
|
||||||
|
|
||||||
if circuit_oc and circuit_oc.sections_count and circuit_oc.sections_count == 0 then
|
script.on_nth_tick(10, function(event)
|
||||||
circuit_oc.add_section()
|
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
|
||||||
|
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
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local val = circuit_oc.get_slot(1).min or 0
|
||||||
|
|
||||||
|
if val == 1 or val == 3 then
|
||||||
|
-- read_type_technology_dropdown
|
||||||
|
local n = 11
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
n = n + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
circuit_oc = circuit_oc.sections[1]
|
for i = n, 17 do
|
||||||
local cs1 = circuit_oc.get_slot(1)
|
circuit_oc.clear_slot(i)
|
||||||
|
|
||||||
if not (cs1 or (cs1.value and cs1.value.name and cs1.value.name == 'signal-SA')) then
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local val = circuit_oc.get_slot(1).min or 0
|
circuit_oc.set_slot(18, {value = {type = 'virtual', name = 'signal-PA', quality = 'normal'}, min = storage.phi_cl.combinator.research_progress})
|
||||||
|
end
|
||||||
|
|
||||||
if val == 1 or val == 3 then
|
--[[
|
||||||
-- read_type_technology_dropdown
|
|
||||||
local n = 11
|
|
||||||
|
|
||||||
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})
|
|
||||||
|
|
||||||
n = n + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = n, 17 do
|
|
||||||
circuit_oc.clear_slot(i)
|
|
||||||
end
|
|
||||||
|
|
||||||
circuit_oc.set_slot(18, {value = {type = 'virtual', name = 'signal-PA', quality = 'normal'}, min = storage.phi_cl.combinator.research_progress})
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
if val == 2 or val == 3 then
|
if val == 2 or val == 3 then
|
||||||
-- incomplete
|
-- incomplete
|
||||||
-- set_type_technology_dropdown
|
-- set_type_technology_dropdown
|
||||||
@@ -414,8 +433,7 @@ script.on_nth_tick(1800, function(_)
|
|||||||
end
|
end
|
||||||
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