This commit is contained in:
2025-03-27 00:10:58 +09:00
parent 2c67785828
commit 0aee25d469

View File

@@ -108,8 +108,8 @@ if settings.startup['PHI-CT'].value then
end end
function inserter_utils.get_max_range(inserter) function inserter_utils.get_max_range(inserter)
local pickup_pos = math2d.position.ensure_xy(math2d.position.add(inserter.prototype.inserter_pickup_position, {0.5, 0.5})) local pickup_pos = math2d.position.ensure_xy(math2d.position.add(inserter.inserter_pickup_position, {0.5, 0.5}))
local drop_pos = math2d.position.ensure_xy(math2d.position.add(inserter.prototype.inserter_drop_position, {0.5, 0.5})) local drop_pos = math2d.position.ensure_xy(math2d.position.add(inserter.inserter_drop_position, {0.5, 0.5}))
return math.max(math.abs(math.floor(pickup_pos.x)), math.abs(math.floor(pickup_pos.y)), math.abs(math.floor(drop_pos.x)), math.abs(math.floor(drop_pos.y))) return math.max(math.abs(math.floor(pickup_pos.x)), math.abs(math.floor(pickup_pos.y)), math.abs(math.floor(drop_pos.x)), math.abs(math.floor(drop_pos.y)))
end end
@@ -122,10 +122,9 @@ if settings.startup['PHI-CT'].value then
local frame_content = frame_main.add({type = 'frame', name = 'frame_content', style = 'entity_frame'}) local frame_content = frame_main.add({type = 'frame', name = 'frame_content', style = 'entity_frame'})
local flow_content = frame_content.add({type = 'flow', name = 'flow_content', direction = 'vertical'}) local flow_content = frame_content.add({type = 'flow', name = 'flow_content', direction = 'vertical'})
local table_range = 1 local table_range = 1
local inserter_prototyes = prototypes.get_entity_filtered({{filter = 'type', type = 'inserter'}})
for _, prototype in pairs(inserter_prototyes) do for _, inserter in pairs(prototypes.get_entity_filtered({{filter = 'type', type = 'inserter'}})) do
table_range = math.max(table_range, inserter_utils.get_max_range(prototype)) table_range = math.max(table_range, inserter_utils.get_max_range(inserter))
end end
local table_position = flow_content.add({type = 'table', name = 'table_position', column_count = 1 + table_range * 2}) local table_position = flow_content.add({type = 'table', name = 'table_position', column_count = 1 + table_range * 2})
@@ -161,7 +160,7 @@ if settings.startup['PHI-CT'].value then
function gui.update(player, inserter) function gui.update(player, inserter)
local gui_instance = player.gui.relative.inserter_config.frame_content.flow_content local gui_instance = player.gui.relative.inserter_config.frame_content.flow_content
local table_range = (gui_instance.table_position.column_count - 1) / 2 local table_range = (gui_instance.table_position.column_count - 1) / 2
local inserter_range = inserter_utils.get_max_range(inserter) local inserter_range = inserter_utils.get_max_range(inserter.prototype or inserter.ghost_prototype)
local arm_positions = inserter_utils.get_arm_positions(inserter) local arm_positions = inserter_utils.get_arm_positions(inserter)
local idx = 0 local idx = 0
@@ -270,7 +269,7 @@ if settings.startup['PHI-CT'].value then
if e.destination.type == 'inserter' or (e.destination.type == 'entity-ghost' and e.destination.ghost_type == 'inserter') then if e.destination.type == 'inserter' or (e.destination.type == 'entity-ghost' and e.destination.ghost_type == 'inserter') then
e.destination.direction = e.source.direction e.destination.direction = e.source.direction
local arm_positions = inserter_utils.get_arm_positions(e.destination) local arm_positions = inserter_utils.get_arm_positions(e.destination)
local max_range = inserter_utils.get_max_range(e.destination) local max_range = inserter_utils.get_max_range(e.destination.prototype or e.destination.ghost_prototype)
for _, v in pairs({'drop', 'pickup'}) do for _, v in pairs({'drop', 'pickup'}) do
if math.max(math.abs(arm_positions[v].x), math.abs(arm_positions[v].y)) > max_range then if math.max(math.abs(arm_positions[v].x), math.abs(arm_positions[v].y)) > max_range then