SHARE
TWEET

Untitled

a guest Jul 19th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int long_count = 0;
  2. int deep_count = 0;
  3.  
  4. void Main(string argument)
  5. {
  6.   // block declarations
  7.   string ERR_TXT = "";
  8.   List<IMyTerminalBlock> l4 = new List<IMyTerminalBlock>();
  9.   IMyShipDrill v4 = null;
  10.   GridTerminalSystem.GetBlocksOfType<IMyShipDrill>(l4);
  11.   if(l4.Count == 0) {
  12.     ERR_TXT += "no Drill blocks found\n";
  13.   }
  14.   else {
  15.     for(int i = 0; i < l4.Count; i++) {
  16.       if(l4[i].CustomName == "mining_drill") {
  17.         v4 = (IMyShipDrill)l4[i];
  18.         break;
  19.       }
  20.     }
  21.     if(v4 == null) {
  22.       ERR_TXT += "no Drill block named mining_drill found\n";
  23.     }
  24.   }
  25.   List<IMyTerminalBlock> l5 = new List<IMyTerminalBlock>();
  26.   IMyMotorAdvancedStator v5 = null;
  27.   GridTerminalSystem.GetBlocksOfType<IMyMotorAdvancedStator>(l5);
  28.   if(l5.Count == 0) {
  29.     ERR_TXT += "no Advanced Rotor blocks found\n";
  30.   }
  31.   else {
  32.     for(int i = 0; i < l5.Count; i++) {
  33.       if(l5[i].CustomName == "mining_angle") {
  34.         v5 = (IMyMotorAdvancedStator)l5[i];
  35.         break;
  36.       }
  37.     }
  38.     if(v5 == null) {
  39.       ERR_TXT += "no Advanced Rotor block named mining_angle found\n";
  40.     }
  41.   }
  42.   List<IMyTerminalBlock> v6 = new List<IMyTerminalBlock>();
  43.   GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(v6);
  44.   if(v6.Count == 0) {
  45.     ERR_TXT += "no Piston blocks found\n";
  46.   }
  47.   List<IMyTerminalBlock> v9 = new List<IMyTerminalBlock>();
  48.   if(GridTerminalSystem.GetBlockGroupWithName("mining_refinery") != null) {
  49.     GridTerminalSystem.GetBlockGroupWithName("mining_refinery").GetBlocksOfType<IMyRefinery>(v9);
  50.     if(v9.Count == 0) {
  51.       ERR_TXT += "group mining_refinery has no Refinery blocks\n";
  52.     }
  53.   }
  54.   else {
  55.     ERR_TXT += "group mining_refinery not found\n";
  56.   }
  57.   List<IMyTerminalBlock> l12 = new List<IMyTerminalBlock>();
  58.   IMyPistonBase v12 = null;
  59.   GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(l12);
  60.   if(l12.Count == 0) {
  61.     ERR_TXT += "no Piston blocks found\n";
  62.   }
  63.   else {
  64.     for(int i = 0; i < l12.Count; i++) {
  65.       if(l12[i].CustomName == "mining_long") {
  66.         v12 = (IMyPistonBase)l12[i];
  67.         break;
  68.       }
  69.     }
  70.     if(v12 == null) {
  71.       ERR_TXT += "no Piston block named mining_long found\n";
  72.     }
  73.   }
  74.   List<IMyTerminalBlock> v17 = new List<IMyTerminalBlock>();
  75.   if(GridTerminalSystem.GetBlockGroupWithName("mining_deep_pistons") != null) {
  76.     GridTerminalSystem.GetBlockGroupWithName("mining_deep_pistons").GetBlocksOfType<IMyPistonBase>(v17);
  77.     if(v17.Count == 0) {
  78.       ERR_TXT += "group mining_deep_pistons has no Piston blocks\n";
  79.     }
  80.   }
  81.   else {
  82.     ERR_TXT += "group mining_deep_pistons not found\n";
  83.   }
  84.  
  85.   // display errors
  86.   if(ERR_TXT != "") {
  87.     Echo("Script Errors:\n"+ERR_TXT+"(make sure block ownership is set correctly)");
  88.     return;
  89.   }
  90.   else {Echo("");}
  91.  
  92.   // logic
  93.   if(getDegrees(v5.Angle) > 84 || (getDegrees(v5.Angle) < 276)) {
  94.     v5.ApplyAction("Reverse");
  95.     long_count = long_count+1;
  96.   }
  97.  
  98. }
  99.  
  100. const string MULTIPLIERS = ".kMGTPEZY";
  101.  
  102. float getExtraFieldFloat(IMyTerminalBlock block, string regexString) {
  103.   System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(regexString, System.Text.RegularExpressions.RegexOptions.Singleline);
  104.   float result = 0.0f;
  105.   double parsedDouble;
  106.   System.Text.RegularExpressions.Match match = regex.Match(block.DetailedInfo);
  107.   if (match.Success) {
  108.     if (Double.TryParse(match.Groups[1].Value, out parsedDouble)) {
  109.       result = (float) parsedDouble;
  110.     }
  111.     if(MULTIPLIERS.IndexOf(match.Groups[2].Value) > -1) {
  112.       result = result * (float) Math.Pow(1000.0, MULTIPLIERS.IndexOf(match.Groups[2].Value));
  113.     }
  114.   }
  115.   return result;
  116. }
  117.  
  118. float getDegrees(float rad) {
  119.   return (float) (rad * (180/Math.PI));
  120. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top