Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
- double x0, dx;
- double y0, dy;
- double z0, dz;
- double speed;
- double speedMultiplier = 1500000;
- float ThrustSpeed;
- double setSpeed = 0.008;
- string command = "stop";
- void Main(string argument)
- {
- string[] command = argument.Split(new char[] { ' ' }, 2);
- List<IMyTerminalBlock> getCockpit = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyCockpit>(getCockpit);
- // Wir brauchen nur einen
- if (getCockpit.Count > 1) new Exception("Zuviele Cockpits");
- if (!sameGrid(getCockpit[0])) new Exception("Kein Cockpit am Schiff");
- IMyCockpit Cockpit = (IMyCockpit)getCockpit[0];
- double x = Math.Round(Cockpit.GetPosition().GetDim(0), 3);
- double y = Math.Round(Cockpit.GetPosition().GetDim(1), 3);
- double z = Math.Round(Cockpit.GetPosition().GetDim(2), 3);
- dx = x - x0;
- dy = y - y0;
- dz = z - z0;
- x0 = x;
- y0 = y;
- z0 = z;
- switch (command[0].ToString().ToLower())
- {
- case "start": // Beginnen
- setThrusterSpeed(0.004);
- break;
- case "add": // Schneller
- setThrusterSpeed(0.001);
- break;
- case "rem": // Langsamer
- setThrusterSpeed(-0.001);
- break;
- case "stop": // Stop
- setThrusterSpeed(0);
- break;
- }
- Echo("Script: " + "\n" + "x " + x + " y " + y + " z " + z + "\n" + "speed (units/tick) " + speed);
- }
- public bool sameGrid(IMyTerminalBlock block)
- {
- if (Me.CubeGrid == block.CubeGrid)
- return true;
- return false;
- }
- public void setThrusterSpeed(double hasSpeed)
- {
- setSpeed = setSpeed + hasSpeed;
- double speed = Math.Round(Math.Sqrt(dx * dx + dy * dy + dz * dz), 5);
- ThrustSpeed = (float)(hasSpeed - speed) * (float)speedMultiplier;
- List<IMyTerminalBlock> getThrusts = new List<IMyTerminalBlock>();
- GridTerminalSystem.SearchBlocksOfName("(Forward:Script)", getThrusts);
- foreach (IMyThrust Thrust in getThrusts)
- {
- Thrust.SetValueFloat("Override", ThrustSpeed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment