Suicide_Jack

Untitled

Feb 16th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
  2. double x0, dx;
  3. double y0, dy;
  4. double z0, dz;
  5. double speed;
  6. double speedMultiplier = 1500000;
  7. float ThrustSpeed;
  8. double setSpeed = 0.008;
  9. string command = "stop";
  10.  
  11. void Main(string argument)
  12. {
  13. string[] command = argument.Split(new char[] { ' ' }, 2);
  14.  
  15.  
  16. List<IMyTerminalBlock> getCockpit = new List<IMyTerminalBlock>();
  17. GridTerminalSystem.GetBlocksOfType<IMyCockpit>(getCockpit);
  18.  
  19. // Wir brauchen nur einen
  20. if (getCockpit.Count > 1) new Exception("Zuviele Cockpits");
  21. if (!sameGrid(getCockpit[0])) new Exception("Kein Cockpit am Schiff");
  22.  
  23. IMyCockpit Cockpit = (IMyCockpit)getCockpit[0];
  24.  
  25. double x = Math.Round(Cockpit.GetPosition().GetDim(0), 3);
  26. double y = Math.Round(Cockpit.GetPosition().GetDim(1), 3);
  27. double z = Math.Round(Cockpit.GetPosition().GetDim(2), 3);
  28.  
  29. dx = x - x0;
  30. dy = y - y0;
  31. dz = z - z0;
  32. x0 = x;
  33. y0 = y;
  34. z0 = z;
  35.  
  36. switch (command[0].ToString().ToLower())
  37. {
  38. case "start": // Beginnen
  39. setThrusterSpeed(0.004);
  40. break;
  41.  
  42. case "add": // Schneller
  43. setThrusterSpeed(0.001);
  44. break;
  45.  
  46. case "rem": // Langsamer
  47. setThrusterSpeed(-0.001);
  48. break;
  49.  
  50. case "stop": // Stop
  51. setThrusterSpeed(0);
  52. break;
  53. }
  54.  
  55. Echo("Script: " + "\n" + "x " + x + " y " + y + " z " + z + "\n" + "speed (units/tick) " + speed);
  56.  
  57.  
  58.  
  59. }
  60.  
  61. public bool sameGrid(IMyTerminalBlock block)
  62. {
  63. if (Me.CubeGrid == block.CubeGrid)
  64. return true;
  65. return false;
  66. }
  67.  
  68. public void setThrusterSpeed(double hasSpeed)
  69. {
  70. setSpeed = setSpeed + hasSpeed;
  71.  
  72. double speed = Math.Round(Math.Sqrt(dx * dx + dy * dy + dz * dz), 5);
  73. ThrustSpeed = (float)(hasSpeed - speed) * (float)speedMultiplier;
  74.  
  75. List<IMyTerminalBlock> getThrusts = new List<IMyTerminalBlock>();
  76. GridTerminalSystem.SearchBlocksOfName("(Forward:Script)", getThrusts);
  77.  
  78. foreach (IMyThrust Thrust in getThrusts)
  79. {
  80. Thrust.SetValueFloat("Override", ThrustSpeed);
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment