mirror of
https://github.com/PHIDIAS0303/factorio-mod-PHI.git
synced 2026-05-13 05:08:44 +09:00
.
This commit is contained in:
+6
-44
@@ -61,50 +61,17 @@ if settings.startup['PHI-MI'].value or (settings.startup['PHI-GM'].value and set
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
script.on_event(defines.events.on_gui_selection_state_changed, function(event)
|
script.on_event(defines.events.on_gui_selection_state_changed, combinator.on_gui_selection_state_changed)
|
||||||
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_player_rotated_entity, defines.events.on_player_flipped_entity}, function(event)
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = game.players[event.player_index]
|
gui_update(game.players[event.player_index], game.players[event.player_index].opened)
|
||||||
|
|
||||||
if not event.entity then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if player.opened ~= event.entity then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
gui_update(player, player.opened)
|
|
||||||
end)
|
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)
|
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)
|
||||||
entity_build(event)
|
|
||||||
end)
|
|
||||||
|
|
||||||
script.on_event(defines.events.on_entity_cloned, function(event)
|
script.on_event(defines.events.on_entity_cloned, function(event)
|
||||||
entity_build({entity=event.destination})
|
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
script.on_nth_tick(1800, function(_)
|
script.on_nth_tick(1800, combinator.on_nth_tick_1800)
|
||||||
combinator.on_nth_tick_1800()
|
script.on_nth_tick(10, combinator.on_nth_tick_10)
|
||||||
end)
|
|
||||||
|
|
||||||
script.on_nth_tick(10, function(_)
|
|
||||||
combinator.on_nth_tick_10()
|
|
||||||
end)
|
|
||||||
|
|||||||
@@ -70,6 +70,23 @@ function main.gui_update(player, entity)
|
|||||||
dropdown.selected_index = ((val < 0 or val > 3) and 1) or (val + 1)
|
dropdown.selected_index = ((val < 0 or val > 3) and 1) or (val + 1)
|
||||||
end
|
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)
|
function main.handle_research_queue(entity, combinator)
|
||||||
local combinator_slot = combinator.get_slot(1)
|
local combinator_slot = combinator.get_slot(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user