Exemplo n.º 1
0
        public void Main(string argument, UpdateType updateSource)
        {
            IMyCockpit       myCockpit   = (IMyCockpit)GridTerminalSystem.GetBlockWithName("Cockpit");
            List <IMyThrust> upthrusters = new List <IMyThrust>();



            upthrusters = GetMyUpThrusts("ThrustUP");


            double gravity = myCockpit.GetNaturalGravity().Length() / 9.81;
            double speed   = myCockpit.GetShipSpeed();

            Echo($"ship speed = {speed.ToString()}");
            Echo(gravity.ToString());

            if (gravity > 0.30)
            {
                foreach (IMyThrust ThrustUP in upthrusters)
                {
                    ThrustUP.Enabled = true;
                    ThrustUP.ThrustOverridePercentage = 70;
                }
                Echo("im here 1");
            }
            else
            {
                foreach (IMyThrust ThrustUP in upthrusters)
                {
                    ThrustUP.Enabled = false;
                    ThrustUP.ThrustOverridePercentage = 0;
                }
                Echo("im here 2");
            }
        }
Exemplo n.º 2
0
        private void UpdateShipInfo()
        {
            ShipInfo.Clear();
            ShipInfo.Append("Autopilot: ");
            if (Pilot.Tasks.Count == 0)
            {
                ShipInfo.Append("idle");
            }
            else if (Pilot.Tasks[0] is DockingStrategy)
            {
                ShipInfo.Append("dock");
            }
            else
            {
                ShipInfo.Append("route");
            }
            ShipInfo.Append('\n');
            ShipInfo.Append($"Speed: {Cockpit.GetShipSpeed():F1}m/s\n");
            ShipInfo.Append("Dampeners: ");
            ShipInfo.Append(Cockpit.DampenersOverride ? "on\n" : "OFF\n");
            ShipInfo.Append("Connector: ");
            if (!Connector.IsFunctional)
            {
                ShipInfo.Append("BROKEN\n");
            }
            else
            {
                switch (Connector.Status)
                {
                case MyShipConnectorStatus.Connected: ShipInfo.Append("DOCKED\n"); break;

                case MyShipConnectorStatus.Connectable: ShipInfo.Append("READY\n"); break;

                default: ShipInfo.Append("n/a\n"); break;
                }
            }
            double charge = Batteries.Average((b) => b.CurrentStoredPower / b.MaxStoredPower) * 100.0;

            ShipInfo.Append($"Batteries: {charge:F1}%\n");
            if (Front.AvailableScanRange < 1e5)
            {
                ShipInfo.Append($"Scan: {Front.AvailableScanRange / 1000.0:F1}km\n");
            }
            Left.WriteText(ShipInfo);
        }
Exemplo n.º 3
0
        // This file contains your actual script.
        //
        // You can either keep all your code here, or you can create separate
        // code files to make your program easier to navigate while coding.
        //
        // In order to add a new utility class, right-click on your project,
        // select 'New' then 'Add Item...'. Now find the 'Space Engineers'
        // category under 'Visual C# Items' on the left hand side, and select
        // 'Utility Class' in the main area. Name it in the box below, and
        // press OK. This utility class will be merged in with your code when
        // deploying your final script.
        //
        // You can also simply create a new utility class manually, you don't
        // have to use the template if you don't want to. Just do so the first
        // time to see what a utility class looks like.



        public void Main(string argument, UpdateType updateSource)

        {
            Runtime.UpdateFrequency = UpdateFrequency.Update1;

            IMyCockpit myCockpit = (IMyCockpit)GridTerminalSystem.GetBlockWithName("Cockpit");

            List <IMyThrust> forwardthrusters = new List <IMyThrust>();
            List <IMyThrust> breakthrusters   = new List <IMyThrust>();

            forwardthrusters = GetMyForwardThrusts("ThrustForward");
            breakthrusters   = GetMyBreakThrusts("ThrustBackward");


            double speed = myCockpit.GetShipSpeed();

            Echo($"ship speed = {speed.ToString()}");


            if (speed < 2 && 4 > speed)
            {
                foreach (IMyThrust forwardThrust in forwardthrusters)
                {
                    forwardThrust.Enabled = true;
                    forwardThrust.ThrustOverridePercentage = 1;
                }
            }
            else if (speed > 20 && speed < 30)
            {
                foreach (IMyThrust forwardThrust in forwardthrusters)
                {
                    forwardThrust.Enabled = false;
                    forwardThrust.ThrustOverridePercentage = 1;
                }
            }
        }