Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Program()
- {
- Runtime.UpdateFrequency = UpdateFrequency.Update100; // Run Main() every 100 ticks, or about 1.3s
- }
- public void Main()
- {
- checkThrusters(); // I didn't put the code directly into Main() so you can cut and paste below into any other PB
- }
- int minimumCount = 10; // Minimum number of operating test blocks
- string testTag = "Thruster"; // Can be any part of the test block's name (e.g. Thruster Left, Ion Thruster)
- string activateTag = "Black Smoke"; // Can be any part of the effector blocks name
- public void checkThrusters()
- {
- var tbList = new List<IMyTerminalBlock>();
- GridTerminalSystem.SearchBlocksOfName(testTag, tbList);
- var working = tbList.Count();
- // This next section tests each block, and if it's not working(damaged, grinded down, turned off) takes it out of the "working" count.
- foreach (var tb in tbList)
- if (!((tb as IMyFunctionalBlock).IsFunctional))
- working--;
- GridTerminalSystem.SearchBlocksOfName(activateTag, tbList);
- foreach (var tb in tbList)
- (tb as IMyFunctionalBlock).Enabled = (working < minimumCount); // Turns activate blocks on/off
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement