Zgragselus

Space Engineers: Airlock Close

Sep 26th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. public Program()
  2. {
  3. // The constructor, called only once every session and
  4. // always before any other method is called. Use it to
  5. // initialize your script.
  6. //
  7. // The constructor is optional and can be removed if not
  8. // needed.
  9. //
  10. // It's recommended to set RuntimeInfo.UpdateFrequency
  11. // here, which will allow your script to run itself without a
  12. // timer block.
  13. }
  14.  
  15. public void Save()
  16. {
  17. // Called when the program needs to save its state. Use
  18. // this method to save your state to the Storage field
  19. // or some other means.
  20. //
  21. // This method is optional and can be removed if not
  22. // needed.
  23. }
  24.  
  25. // Method for finding blocks by names
  26. List<IMyTerminalBlock> SearchBlocksByName(string blockName) {
  27. var blocks = new List<IMyTerminalBlock>();
  28. GridTerminalSystem.SearchBlocksOfName(blockName, blocks);
  29. return blocks;
  30. }
  31.  
  32. public void Main(string argument, UpdateType updateSource)
  33. {
  34. List<IMyTerminalBlock> doors = new List<IMyTerminalBlock>();
  35. GridTerminalSystem.GetBlocksOfType<IMyDoor>(doors);
  36. List<IMyDoor> hangarDoors = new List<IMyDoor>();
  37.  
  38. for (int i = 0; i < doors.Count; i++)
  39. {
  40. if (doors[i].CustomName.Contains("Airtight"))
  41. {
  42. hangarDoors.Add(doors[i] as IMyDoor);
  43. }
  44. }
  45.  
  46. for (int i = 0; i < hangarDoors.Count; i++)
  47. {
  48. hangarDoors[i].ApplyAction("Open_Off");
  49. }
  50.  
  51. IMyTimerBlock time = GridTerminalSystem.GetBlockWithName("Timer Block") as IMyTimerBlock;
  52. time.ApplyAction("OnOff_On");
  53. time.ApplyAction("Stop");
  54.  
  55. var vents = SearchBlocksByName("AirHangar");
  56. List<IMyAirVent> airVents = new List<IMyAirVent>();
  57. for (int i = 0; i < vents.Count; i++)
  58. {
  59. airVents.Add(vents[i] as IMyAirVent);
  60. }
  61.  
  62. for (int i = 0; i < airVents.Count(); i++)
  63. {
  64. airVents[i].ApplyAction("Depressurize_Off");
  65. }
  66. }
  67.  
Add Comment
Please, Sign In to add comment