public void Transfer() { Echo("###--- Transfersystem 2000 started"); List <IMyTerminalBlock> toCargoContainerList = new List <IMyTerminalBlock> (); List <IMyTerminalBlock> fromCargoContainerList = new List <IMyTerminalBlock> (); for (int nIndex = 0; nIndex < m_transferItemList.Length; nIndex++) { toCargoContainerList.Clear(); TransferItem transferItem = m_transferItemList[nIndex]; MyItemType itemType = GetItemType(transferItem.Type); GridTerminalSystem.GetBlocksOfType(toCargoContainerList, searchItem => searchItem.CustomName.Contains(transferItem.TagTo)); for (int nToContainerIndex = 0; nToContainerIndex < toCargoContainerList.Count; nToContainerIndex++) { IMyInventory toInventory = toCargoContainerList[nToContainerIndex].GetInventory(); fromCargoContainerList.Clear(); GridTerminalSystem.GetBlocksOfType(fromCargoContainerList, searchItem => searchItem.CustomName.Contains(transferItem.TagFrom)); for (int nFromContainerIndex = 0; nFromContainerIndex < fromCargoContainerList.Count; nFromContainerIndex++) { MyInventoryItem?steelPlateFoundTo = toInventory.FindItem(itemType); VRage.MyFixedPoint diffAmount = transferItem.Amount; if ((steelPlateFoundTo.HasValue)) { diffAmount = diffAmount - steelPlateFoundTo.Value.Amount; } if (0 < diffAmount) { IMyInventory fromInventory = fromCargoContainerList[nFromContainerIndex].GetInventory(); MyInventoryItem?steelPlateFound = fromInventory.FindItem(itemType); if (steelPlateFound.HasValue) { fromInventory.TransferItemTo(toInventory, steelPlateFound.Value, diffAmount); } } } } } Echo("###--- Transfersystem 2000 finished"); }