Intruder Detection Reset No rating results yet

posted in: Control, Operations, Scripts | 1

Please see the companion script to this one for instructions on how to use it: Intruder Detection.

  1. const String lightsName = "Interior Light";
  2. const String lightGroupName = "Intruder Lights";
  3. const String lightGroupOrName = "Group";
  4.  
  5. const String turretsName = "Interior Turret";
  6. const String turretGroupName = "Defensive Turrets";
  7. const String turretGroupOrName = "Group";
  8. void Main()      
  9. {  
  10.     List<IMyTerminalBlock> lights = new List<IMyTerminalBlock>();
  11.     if (lightGroupOrName.Equals("Group")) {
  12.         lights = getBlockGroup(GridTerminalSystem, lightGroupName);
  13.     } else {
  14.         GridTerminalSystem.SearchBlocksOfName(lightsName, lights);
  15.     }
  16.     Color white = new Color(255, 255, 255);
  17.     for (int i = 0; i < lights.Count; i++)  
  18.     {  
  19.         var l = (IMyInteriorLight)lights&#91;i];    
  20.         l.GetActionWithName("OnOff_Off").Apply(l);
  21.         l.SetValue("Color", white);
  22.         l.SetValue("Blink Lenght", 0.0f);
  23.         l.SetValue("Blink Interval", 0.0f);
  24.         l.GetActionWithName("OnOff_On").Apply(l);
  25.     }  
  26.     List<IMyTerminalBlock> turrets = new List<IMyTerminalBlock>();
  27.     if (turretGroupOrName.Equals("Group")) {
  28.         turrets = getBlockGroup(GridTerminalSystem, turretGroupName);
  29.     } else {
  30.         GridTerminalSystem.SearchBlocksOfName(turretsName, turrets);
  31.     }
  32.    
  33.     for (int i = 0; i < turrets.Count; i++)  
  34.     {  
  35.         var t = (IMyLargeTurretBase)turrets&#91;i];    
  36.         t.EnableIdleRotation = false;
  37.     }  
  38.  
  39. }
  40.  
  41. public static List<IMyTerminalBlock> getBlockGroup(IMyGridTerminalSystem searchGrid, String groupName) {        
  42.   for(int g=0; g<searchGrid.BlockGroups.Count; g++) {        
  43.     if( searchGrid.BlockGroups&#91;g].Name == groupName) {        
  44.       return searchGrid.BlockGroups&#91;g].Blocks;        
  45.     }          
  46.   }        
  47.   return new List<IMyTerminalBlock>();        
  48. }

Please rate this post

One Response

  1. […] This script can be used as intruder detection. To use it, you also need the companion script: Intruder Detection Reset. […]

Leave a Reply