From 3609e1526e8a16151b480145f3ba2af963b5f4f9 Mon Sep 17 00:00:00 2001 From: cswimr Date: Thu, 7 Nov 2024 20:30:19 -0500 Subject: [PATCH] finishing up docking and undocking polling logic --- Program.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index d0763e5..5b320db 100644 --- a/Program.cs +++ b/Program.cs @@ -391,7 +391,8 @@ namespace IngameScript Echo("Polling..."); List connectors = new List(); - // Get all connectors on the grid + // Get all connectors on the grid that are managed by the script + Echo($"Retrieving connectors, filtering by \"{_connectorPrefix}\"..."); GridTerminalSystem.GetBlocksOfType( connectors, connector => @@ -403,13 +404,39 @@ namespace IngameScript { foreach (IMyShipConnector connector in connectors) { - if (connector.IsConnected == _isDocked) + if (connector.IsConnected == true) { + Echo($"Connector '{connector.CustomName}' is connected. Exiting."); return; } + else + { + Echo( + $"Connector '{connector.CustomName}' is not connected. Continuing." + ); + } } + Echo("No connectors are connected. Undocking..."); Undock(); } + else if (_isDocked == false) + { + foreach (IMyShipConnector connector in connectors) + { + if (connector.IsConnected == true) + { + Echo($"Connector '{connector.CustomName}' is connected. Docking..."); + Dock(); + break; + } + else + { + Echo( + $"Connector '{connector.CustomName}' is not connected. Continuing." + ); + } + } + } } else {