Compare commits

..

2 commits

View file

@ -177,6 +177,7 @@ namespace IngameScript
_storageIni.Clear(); _storageIni.Clear();
_storageIni.Set("AutomaticConnectorActions", "Is_Docked", _isDocked); _storageIni.Set("AutomaticConnectorActions", "Is_Docked", _isDocked);
Storage = _storageIni.ToString(); Storage = _storageIni.ToString();
Echo($"Docking status set to {_isDocked} and saved to internal storage.");
} }
private void Dock() private void Dock()
@ -390,7 +391,8 @@ namespace IngameScript
Echo("Polling..."); Echo("Polling...");
List<IMyShipConnector> connectors = new List<IMyShipConnector>(); List<IMyShipConnector> connectors = new List<IMyShipConnector>();
// 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( GridTerminalSystem.GetBlocksOfType(
connectors, connectors,
connector => connector =>
@ -402,13 +404,39 @@ namespace IngameScript
{ {
foreach (IMyShipConnector connector in connectors) foreach (IMyShipConnector connector in connectors)
{ {
if (connector.IsConnected == _isDocked) if (connector.IsConnected == true)
{ {
Echo($"Connector '{connector.CustomName}' is connected. Exiting.");
return; return;
} }
else
{
Echo(
$"Connector '{connector.CustomName}' is not connected. Continuing."
);
} }
}
Echo("No connectors are connected. Undocking...");
Undock(); 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 else
{ {