Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Main()
- {
- // What the cargo cans' custom names need to start with.
- string groupName = "Cargo";
- // What the graph LCD's custom name needs to be.
- string lcdName = "LCD";
- // I don't want to type GridTerminalSystem.BlockGroups a lot, so let's save it to a variable.
- var groups = GridTerminalSystem.BlockGroups;
- // This will be the group we actually want. We don't have a value to start it off with, so we set it to "null".
- IMyBlockGroup myGroup = null;
- // Find the group we want.
- for(int i=0; i<groups.Count; i++) {
- if(groups[i].Name == groupName) {
- myGroup = groups[i];
- }
- }
- if (myGroup == null) throw new Exception("Cargo Group not found, check name");
- // This list will hold all the cargo containers we actually want.
- List<IMyTerminalBlock> blocks = myGroup.Blocks;
- // The total amount of space used
- float usedVolume = 0.0f;
- // The total capacity of the cargo cans
- float maxVolume = 0.0f;
- // Count the total space used and the total capacity of the cargo cans
- for(int i=0; i<blocks.Count; i++) {
- var b = blocks[i];
- usedVolume += (float)b.GetInventory(0).CurrentVolume;
- maxVolume += (float)b.GetInventory(0).MaxVolume;
- }
- // Find the LCD for the summary graph
- var lcd = GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;
- if (lcd == null) throw new Exception("LCD block not found, check name");
- if (lcd != null) {
- int index = (int)(20.0f * usedVolume / maxVolume);
- lcd.ClearImagesFromSelection();
- switch (index) {
- case 0:
- lcd.AddImageToSelection("Percent 000");
- break;
- case 1:
- lcd.AddImageToSelection("Percent 005");
- break;
- case 2:
- lcd.AddImageToSelection("Percent 010");
- break;
- case 3:
- lcd.AddImageToSelection("Percent 015");
- break;
- case 4:
- lcd.AddImageToSelection("Percent 020");
- break;
- case 5:
- lcd.AddImageToSelection("Percent 025");
- break;
- case 6:
- lcd.AddImageToSelection("Percent 030");
- break;
- case 7:
- lcd.AddImageToSelection("Percent 035");
- break;
- case 8:
- lcd.AddImageToSelection("Percent 040");
- break;
- case 9:
- lcd.AddImageToSelection("Percent 045");
- break;
- case 10:
- lcd.AddImageToSelection("Percent 050");
- break;
- case 11:
- lcd.AddImageToSelection("Percent 055");
- break;
- case 12:
- lcd.AddImageToSelection("Percent 060");
- break;
- case 13:
- lcd.AddImageToSelection("Percent 065");
- break;
- case 14:
- lcd.AddImageToSelection("Percent 070");
- break;
- case 15:
- lcd.AddImageToSelection("Percent 075");
- break;
- case 16:
- lcd.AddImageToSelection("Percent 080");
- break;
- case 17:
- lcd.AddImageToSelection("Percent 085");
- break;
- case 18:
- lcd.AddImageToSelection("Percent 090");
- break;
- case 19:
- lcd.AddImageToSelection("Percent 095");
- break;
- case 20:
- lcd.AddImageToSelection("Percent 100");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment