Morphik08

Space Engineers: Group Cargo Display with Images

Jul 6th, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.55 KB | None | 0 0
  1. void Main()  
  2. {  
  3.   // What the cargo cans' custom names need to start with.  
  4.   string groupName = "Welder 1 Cargo";  
  5.    
  6.   // What the graph LCD's custom name needs to be.  
  7.   string lcdName = "CapWeld1";  
  8.    
  9.   // I don't want to type GridTerminalSystem.BlockGroups a lot, so let's save it to a variable.  
  10.   var groups = GridTerminalSystem.BlockGroups;  
  11.    
  12.   // 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".  
  13.   IMyBlockGroup myGroup = null;  
  14.    
  15.   // Find the group we want.  
  16.   for(int i=0; i<groups.Count; i++) {  
  17.     if(groups[i].Name == groupName) {  
  18.       myGroup = groups[i];  
  19.     }  
  20.   }  
  21.    
  22.   // This list will hold all the cargo containers we actually want.  
  23.   List<IMyTerminalBlock> blocks = myGroup.Blocks;  
  24.    
  25.   // The total amount of space used  
  26.   float usedVolume = 0.0f;  
  27.    
  28.   // The total capacity of the cargo cans  
  29.   float maxVolume = 0.0f;  
  30.    
  31.   // Count the total space used and the total capacity of the cargo cans  
  32.   for(int i=0; i<blocks.Count; i++) {  
  33.     var b = blocks[i];  
  34.     usedVolume += (float)b.GetInventory(0).CurrentVolume;  
  35.     maxVolume += (float)b.GetInventory(0).MaxVolume;  
  36.   }  
  37.    
  38.   // The percentage of space used.  
  39.   float pctUsed = 100.0f * usedVolume / maxVolume;  
  40.    
  41.   // Find the LCD we'll use for the summary graph
  42.   var lcd = GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;  
  43.    
  44.    if (lcd != null) {    
  45.     if (pctUsed >= 0 && pctUsed < 5) {    
  46.       lcd.ClearImagesFromSelection();  
  47.       lcd.AddImageToSelection("Percent 000");    
  48.     }    
  49.     if (pctUsed > 5 && pctUsed < 10) {    
  50.       lcd.ClearImagesFromSelection();  
  51.       lcd.AddImageToSelection("Percent 005");    
  52.     }    
  53.     if (pctUsed > 10 && pctUsed < 15) {    
  54.       lcd.ClearImagesFromSelection();  
  55.       lcd.AddImageToSelection("Percent 010");    
  56.     }      
  57.     if (pctUsed > 15 && pctUsed < 20) {    
  58.       lcd.ClearImagesFromSelection();  
  59.       lcd.AddImageToSelection("Percent 015");    
  60.     }  
  61.     if (pctUsed > 20 && pctUsed < 25) {    
  62.       lcd.ClearImagesFromSelection();  
  63.       lcd.AddImageToSelection("Percent 020");  
  64.     }          
  65.     if (pctUsed > 25 && pctUsed < 30) {    
  66.       lcd.ClearImagesFromSelection();  
  67.       lcd.AddImageToSelection("Percent 025");    
  68.     }
  69.     if (pctUsed > 30 && pctUsed < 35) {    
  70.       lcd.ClearImagesFromSelection();  
  71.       lcd.AddImageToSelection("Percent 030");    
  72.     }          
  73.     if (pctUsed > 35 && pctUsed < 40) {    
  74.       lcd.ClearImagesFromSelection();  
  75.       lcd.AddImageToSelection("Percent 035");    
  76.     }
  77.     if (pctUsed > 40 && pctUsed < 45) {    
  78.       lcd.ClearImagesFromSelection();  
  79.       lcd.AddImageToSelection("Percent 040");    
  80.     }          
  81.     if (pctUsed > 45 && pctUsed < 50) {    
  82.       lcd.ClearImagesFromSelection();  
  83.       lcd.AddImageToSelection("Percent 045");    
  84.     }
  85.     if (pctUsed > 50 && pctUsed < 55) {    
  86.       lcd.ClearImagesFromSelection();  
  87.       lcd.AddImageToSelection("Percent 050");    
  88.     }          
  89.     if (pctUsed > 55 && pctUsed < 60) {    
  90.       lcd.ClearImagesFromSelection();  
  91.       lcd.AddImageToSelection("Percent 055");    
  92.     }
  93.     if (pctUsed > 60 && pctUsed < 65) {    
  94.       lcd.ClearImagesFromSelection();  
  95.       lcd.AddImageToSelection("Percent 060");    
  96.     }          
  97.     if (pctUsed > 65 && pctUsed < 70) {    
  98.       lcd.ClearImagesFromSelection();  
  99.       lcd.AddImageToSelection("Percent 065");    
  100.     }
  101.     if (pctUsed > 70 && pctUsed < 75) {    
  102.       lcd.ClearImagesFromSelection();  
  103.       lcd.AddImageToSelection("Percent 070");    
  104.     }          
  105.     if (pctUsed > 75 && pctUsed < 80) {    
  106.       lcd.ClearImagesFromSelection();  
  107.       lcd.AddImageToSelection("Percent 075");    
  108.     }
  109.     if (pctUsed > 80 && pctUsed < 85) {    
  110.       lcd.ClearImagesFromSelection();  
  111.       lcd.AddImageToSelection("Percent 080");    
  112.     }          
  113.     if (pctUsed > 85 && pctUsed < 90) {    
  114.       lcd.ClearImagesFromSelection();  
  115.       lcd.AddImageToSelection("Percent 085");    
  116.     }
  117.     if (pctUsed > 90 && pctUsed < 95) {    
  118.       lcd.ClearImagesFromSelection();  
  119.       lcd.AddImageToSelection("Percent 090");    
  120.     }          
  121.     if (pctUsed > 95 && pctUsed < 99) {    
  122.       lcd.ClearImagesFromSelection();  
  123.       lcd.AddImageToSelection("Percent 095");    
  124.     }
  125.     if (pctUsed >= 99) {    
  126.       lcd.ClearImagesFromSelection();  
  127.       lcd.AddImageToSelection("Percent 100");    
  128.     }      
  129.     }    
  130. }
Advertisement
Add Comment
Please, Sign In to add comment