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 = "Welder 1 Cargo";
- // What the graph LCD's custom name needs to be.
- string lcdName = "CapWeld1";
- // 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];
- }
- }
- // 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;
- }
- // The percentage of space used.
- float pctUsed = 100.0f * usedVolume / maxVolume;
- // Find the LCD we'll use for the summary graph
- var lcd = GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;
- if (lcd != null) {
- if (pctUsed >= 0 && pctUsed < 5) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 000");
- }
- if (pctUsed > 5 && pctUsed < 10) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 005");
- }
- if (pctUsed > 10 && pctUsed < 15) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 010");
- }
- if (pctUsed > 15 && pctUsed < 20) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 015");
- }
- if (pctUsed > 20 && pctUsed < 25) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 020");
- }
- if (pctUsed > 25 && pctUsed < 30) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 025");
- }
- if (pctUsed > 30 && pctUsed < 35) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 030");
- }
- if (pctUsed > 35 && pctUsed < 40) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 035");
- }
- if (pctUsed > 40 && pctUsed < 45) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 040");
- }
- if (pctUsed > 45 && pctUsed < 50) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 045");
- }
- if (pctUsed > 50 && pctUsed < 55) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 050");
- }
- if (pctUsed > 55 && pctUsed < 60) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 055");
- }
- if (pctUsed > 60 && pctUsed < 65) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 060");
- }
- if (pctUsed > 65 && pctUsed < 70) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 065");
- }
- if (pctUsed > 70 && pctUsed < 75) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 070");
- }
- if (pctUsed > 75 && pctUsed < 80) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 075");
- }
- if (pctUsed > 80 && pctUsed < 85) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 080");
- }
- if (pctUsed > 85 && pctUsed < 90) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 085");
- }
- if (pctUsed > 90 && pctUsed < 95) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 090");
- }
- if (pctUsed > 95 && pctUsed < 99) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 095");
- }
- if (pctUsed >= 99) {
- lcd.ClearImagesFromSelection();
- lcd.AddImageToSelection("Percent 100");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment