Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public Program()
  2. {
  3. Runtime.UpdateFrequency = UpdateFrequency.Update100; // Run Main() every 100 ticks, or about 1.3s
  4. }
  5.  
  6. public void Main()
  7. {
  8. checkThrusters(); // I didn't put the code directly into Main() so you can cut and paste below into any other PB
  9. }
  10.  
  11. int minimumCount = 10; // Minimum number of operating test blocks
  12. string testTag = "Thruster"; // Can be any part of the test block's name (e.g. Thruster Left, Ion Thruster)
  13. string activateTag = "Black Smoke"; // Can be any part of the effector blocks name
  14.  
  15. public void checkThrusters()
  16. {
  17. var tbList = new List<IMyTerminalBlock>();
  18. GridTerminalSystem.SearchBlocksOfName(testTag, tbList);
  19. var working = tbList.Count();
  20.  
  21. // This next section tests each block, and if it's not working(damaged, grinded down, turned off) takes it out of the "working" count.
  22. foreach (var tb in tbList)
  23. if (!((tb as IMyFunctionalBlock).IsFunctional))
  24. working--;
  25.  
  26. GridTerminalSystem.SearchBlocksOfName(activateTag, tbList);
  27. foreach (var tb in tbList)
  28. (tb as IMyFunctionalBlock).Enabled = (working < minimumCount); // Turns activate blocks on/off
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement