From 3307b2bf22d6934b87d634a3916853752a51a7a3 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 9 May 2026 22:13:27 +0900 Subject: [PATCH] . --- PHI-CL/control.lua | 50 +++++------------------------------ PHI-CL/control/combinator.lua | 17 ++++++++++++ 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/PHI-CL/control.lua b/PHI-CL/control.lua index 403ac13..f633775 100644 --- a/PHI-CL/control.lua +++ b/PHI-CL/control.lua @@ -61,50 +61,17 @@ if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and set end end) - script.on_event(defines.events.on_gui_selection_state_changed, function(event) - local player = game.players[event.player_index] - - if not (player.opened and player.opened.object_name == 'LuaEntity') then - return - end - - if not player.opened.valid then - return - end - - if player.opened.type == 'constant-combinator' and player.opened.name == 'super-combinator' and player.gui.relative.phi_cl_combinator_config then - local circuit_oc = player.opened.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] - circuit_oc.set_slot(1, {value = {type = 'virtual', name = 'signal-SA', quality = 'normal'}, min = event.element.parent.parent['table_research_queue']['research_queue_dropdown'].selected_index - 1}) - end - end) + script.on_event(defines.events.on_gui_selection_state_changed, combinator.on_gui_selection_state_changed) script.on_event({defines.events.on_player_rotated_entity, defines.events.on_player_flipped_entity}, function(event) - if not event.player_index then + if not event.player_index or not event.entity or game.players[event.player_index].opened ~= event.entity then return end - local player = game.players[event.player_index] - - if not event.entity then - return - end - - if player.opened ~= event.entity then - return - end - - gui_update(player, player.opened) + gui_update(game.players[event.player_index], game.players[event.player_index].opened) end) - script.on_event({defines.events.on_built_entity, defines.events.on_robot_built_entity, defines.events.on_space_platform_built_entity, defines.events.script_raised_built, defines.events.script_raised_revive}, function(event) - entity_build(event) - end) + script.on_event({defines.events.on_built_entity, defines.events.on_robot_built_entity, defines.events.on_space_platform_built_entity, defines.events.script_raised_built, defines.events.script_raised_revive}, entity_build) script.on_event(defines.events.on_entity_cloned, function(event) entity_build({entity=event.destination}) @@ -117,10 +84,5 @@ if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and set end) end -script.on_nth_tick(1800, function(_) - combinator.on_nth_tick_1800() -end) - -script.on_nth_tick(10, function(_) - combinator.on_nth_tick_10() -end) +script.on_nth_tick(1800, combinator.on_nth_tick_1800) +script.on_nth_tick(10, combinator.on_nth_tick_10) diff --git a/PHI-CL/control/combinator.lua b/PHI-CL/control/combinator.lua index 1f326da..24f0055 100644 --- a/PHI-CL/control/combinator.lua +++ b/PHI-CL/control/combinator.lua @@ -70,6 +70,23 @@ function main.gui_update(player, entity) dropdown.selected_index = ((val < 0 or val > 3) and 1) or (val + 1) end +function main.on_gui_selection_state_changed(event) + local player = game.players[event.player_index] + + if not player.opened or not player.opened.object_name or not player.opened.valid or player.opened.object_name ~= 'LuaEntity' or not player.opened.type or player.opened.type ~= 'constant-combinator' or not player.opened.name or player.opened.name ~= 'super-combinator' or not player.gui.relative.phi_cl_combinator_config then + return + end + + local circuit_oc = player.opened.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] + circuit_oc.set_slot(1, {value = {type = 'virtual', name = 'signal-SA', quality = 'normal'}, min = event.element.parent.parent['table_research_queue']['research_queue_dropdown'].selected_index - 1}) +end + function main.handle_research_queue(entity, combinator) local combinator_slot = combinator.get_slot(1)