MINIMUM REQUIREMENTS:

KNOWN ISSUES:

HOW IT WORKS:

Code:

//auto turret evasion script //bug 1: if you travel too fast towards the turret, it will catch your predictable vector. internal List <IMyTerminalBlock> thrusters = new List <IMyTerminalBlock> (); internal List <IMyTerminalBlock> left = new List <IMyTerminalBlock> (); internal List <IMyTerminalBlock> up = new List <IMyTerminalBlock> (); internal List <IMyTerminalBlock> right = new List <IMyTerminalBlock> (); internal List <IMyTerminalBlock> down = new List <IMyTerminalBlock> (); internal IMyTerminalBlock timer; internal bool first_time = true; internal bool end_program = false; internal int state = 0; string block_name = ""; void Main (string argument) { if (first_time) { first_time = false; Initialize (); } switch (argument) { case "stop": end_program = true; ResetVessel (); break; case "run": end_program = false; break; } if (!end_program) { ApplyState (); timer.ApplyAction ("Start"); } } //this method will fetch objects from terminal only once in order to save performance. void Initialize () { GridTerminalSystem.GetBlocksOfType <IMyThrust> (thrusters); timer = GridTerminalSystem.GetBlockWithName ("script timer"); state = 1; for (int a = 0; a < thrusters.Count; a++) { thrusters[a].ApplyAction ("OnOff_On"); block_name = thrusters[a].CustomName; if (block_name.Contains ("left") || block_name.Contains ("Left")) { left.Add (thrusters[a]); } else if (block_name.Contains ("up") || block_name.Contains ("Up")) { up.Add (thrusters[a]); } else if (block_name.Contains ("right") || block_name.Contains ("Right")) { right.Add (thrusters[a]); } else if (block_name.Contains ("down") || block_name.Contains ("Down")) { down.Add (thrusters[a]); } } } //this method cycles through four states which thrust the decoy in a circle, while in the atmosphere. void ApplyState () { switch (state) { case 1: state++; ChangeOverride (left, "on", "no"); ChangeOverride (down, "off", "no"); ChangeOverride (up, "on", "yes"); // i have to separately turn on up thrusters so that damps will affect down. break; case 2: state++; ChangeOverride (up, "on", "no"); ChangeOverride (left, "off", "no"); break; case 3: state++; ChangeOverride (right, "on", "no"); ChangeOverride (up, "off", "no"); break; case 4: state = 1; ChangeOverride (down, "on", "no"); ChangeOverride (up, "off", "yes"); // i have to separately turn off up thrusters so that damps wont affect down. ChangeOverride (right, "off", "no"); break; } } //this method will change thrust override based on argument inputs. void ChangeOverride (List <IMyTerminalBlock> thruster_face, string on_off, string damps_toggle) { for (int a = 0; a < thruster_face.Count; a++) { if (on_off == "off" && damps_toggle == "no") { thruster_face[a].SetValueFloat ("Override", 800.0f); } else if (on_off == "on" && damps_toggle == "no") { thruster_face[a].SetValueFloat ("Override", 80000.0f); } else if (on_off == "off" && damps_toggle == "yes") { up[a].ApplyAction ("OnOff_Off"); } else if (on_off == "on" && damps_toggle == "yes") { up[a].ApplyAction ("OnOff_On"); } } } //this method resets the ship to its normal state if the user inputs a certain string. void ResetVessel () { for (int a = 0; a < thrusters.Count; a++) { thrusters[a].SetValueFloat ("Override", 800.0f); thrusters[a].ApplyAction ("OnOff_On"); } }