Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.41 KB | None | 0 0
  1. int long_count = 0;
  2. int deep_count = 0;
  3.  
  4. public void Main(string argument)
  5. {
  6.   // block declarations
  7.   string ERR_TXT = "";
  8.   List<IMyTerminalBlock> l2 = new List<IMyTerminalBlock>();
  9.   IMyPistonBase v2 = null;
  10.   GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(l2);
  11.   if(l2.Count == 0) {
  12.     ERR_TXT += "no Piston blocks found\n";
  13.   }
  14.   else {
  15.     for(int i = 0; i < l2.Count; i++) {
  16.       if(l2[i].CustomName == "mining_long") {
  17.         v2 = (IMyPistonBase)l2[i];
  18.         break;
  19.       }
  20.     }
  21.     if(v2 == null) {
  22.       ERR_TXT += "no Piston block named mining_long found\n";
  23.     }
  24.   }
  25.   List<IMyTerminalBlock> l3 = new List<IMyTerminalBlock>();
  26.   IMyPistonBase v3 = null;
  27.   GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(l3);
  28.   if(l3.Count == 0) {
  29.     ERR_TXT += "no Piston blocks found\n";
  30.   }
  31.   else {
  32.     for(int i = 0; i < l3.Count; i++) {
  33.       if(l3[i].CustomName == "mining_deep") {
  34.         v3 = (IMyPistonBase)l3[i];
  35.         break;
  36.       }
  37.     }
  38.     if(v3 == null) {
  39.       ERR_TXT += "no Piston block named mining_deep found\n";
  40.     }
  41.   }
  42.   List<IMyTerminalBlock> l4 = new List<IMyTerminalBlock>();
  43.   IMyRefinery v4 = null;
  44.   GridTerminalSystem.GetBlocksOfType<IMyRefinery>(l4);
  45.   if(l4.Count == 0) {
  46.     ERR_TXT += "no Refinery blocks found\n";
  47.   }
  48.   else {
  49.     for(int i = 0; i < l4.Count; i++) {
  50.       if(l4[i].CustomName == "mining_refinery") {
  51.         v4 = (IMyRefinery)l4[i];
  52.         break;
  53.       }
  54.     }
  55.     if(v4 == null) {
  56.       ERR_TXT += "no Refinery block named mining_refinery found\n";
  57.     }
  58.   }
  59.   List<IMyTerminalBlock> l5 = new List<IMyTerminalBlock>();
  60.   IMyMotorAdvancedStator v5 = null;
  61.   GridTerminalSystem.GetBlocksOfType<IMyMotorAdvancedStator>(l5);
  62.   if(l5.Count == 0) {
  63.     ERR_TXT += "no Advanced Rotor blocks found\n";
  64.   }
  65.   else {
  66.     for(int i = 0; i < l5.Count; i++) {
  67.       if(l5[i].CustomName == "mining_rotor") {
  68.         v5 = (IMyMotorAdvancedStator)l5[i];
  69.         break;
  70.       }
  71.     }
  72.     if(v5 == null) {
  73.       ERR_TXT += "no Advanced Rotor block named mining_rotor found\n";
  74.     }
  75.   }
  76.   List<IMyTerminalBlock> l6 = new List<IMyTerminalBlock>();
  77.   IMyShipDrill v6 = null;
  78.   GridTerminalSystem.GetBlocksOfType<IMyShipDrill>(l6);
  79.   if(l6.Count == 0) {
  80.     ERR_TXT += "no Drill blocks found\n";
  81.   }
  82.   else {
  83.     for(int i = 0; i < l6.Count; i++) {
  84.       if(l6[i].CustomName == "mining_drill") {
  85.         v6 = (IMyShipDrill)l6[i];
  86.         break;
  87.       }
  88.     }
  89.     if(v6 == null) {
  90.       ERR_TXT += "no Drill block named mining_drill found\n";
  91.     }
  92.   }
  93.  
  94.   // user variable declarations
  95.   float long_count = 0.0f;
  96.   float deep_count = 0.0f;
  97.  
  98.   // display errors
  99.   if(ERR_TXT != "") {
  100.     Echo("Script Errors:\n"+ERR_TXT+"(make sure block ownership is set correctly)");
  101.     return;
  102.   }
  103.   else {Echo("");}
  104.  
  105.   // logic
  106.   v2.Velocity = (float)0.5;
  107.   v2.MaxLimit = (float)0;
  108.   v3.Velocity = (float)0.5;
  109.   v3.MaxLimit = (float)0;
  110.   if(((IMyRefinery)v4).GetInventory(0).IsFull == true) {
  111.     v5.ApplyAction("OnOff");
  112.     v6.ApplyAction("OnOff");
  113.   }
  114.   if(getDegrees(v5.Angle) > 84 || (getDegrees(v5.Angle) < 276)) {
  115.     v5.ApplyAction("Reverse");
  116.     long_count = +1;
  117.   }
  118.   if(long_count > 1) {
  119.     v2.MaxLimit = (float)2;
  120.     long_count = 0;
  121.     deep_count = +1;
  122.   }
  123.   if(deep_count == 2) {
  124.     v3.MaxLimit = (float)0.75;
  125.     deep_count = 0;
  126.   }
  127. }
  128.  
  129. float getDegrees(float rad) {
  130.   return (float) (rad * (180/Math.PI));
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement