Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Initialize list
- List<IMyCargoContainer> cargoContainerList = new List<IMyCargoContainer>();
- //Get all accessible cargo containers
- GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(cargoContainerList);
- //Get all cargo containers on the same grid by comparing the grid the programmable block is on to each cargo container
- GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(cargoContainerList, block => block.CubeGrid == Me.CubeGrid);
- //Get all cargo containers by name
- string cargoContainerName = "[Count]"; //You will want a setting at the top of the script you can easily change
- string name = cargoContainerName.ToLower(); //Before using it multiple times like this loop below, make a temporary lower case version to compare with the lower case names
- GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(cargoContainerList, block => block.CustomName.ToLower().Contains(name));
- //You can combine the checks to get containers on the same grid with the key in their name
- GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(cargoContainerList, block => block.CubeGrid == Me.CubeGrid && block.CustomName.ToLower().Contains(name));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement