Beispiel #1
0
 //SCRIPTINPUT (FS)
 void init()
 {
     antenna.Enabled = true;
     antenna.SetValue("EnableBroadCast", true);
     if (antenna.TransmitMessage("Init message", MyTransmitTarget.Owned))
     {
         parent.Echo("Com System online");
         ComWorking = true;
     }
     if (!antennaAlwaysOn)
     {
         antenna.SetValue("EnableBroadCast", false);
     }
 }
Beispiel #2
0
        public void Main(string argument, UpdateType updateSource)
        {
            if ((updateSource & UpdateType.Update100) != 0)
            {
                Echo("Hydrogen Level: " + lowH2WarningSystem.GasTanksManager.FilledRatio * 100 + "%");
                lowH2WarningSystem.CheckLevels();
            }
            else if ((updateSource & UpdateType.Terminal) != 0 ||
                     (updateSource & UpdateType.Trigger) != 0)
            {
                string[] words = argument.Split(' ');

                if (argument == "test 1")
                {
                    lowH2WarningSystem.Enabled = true;
                }
                else if (argument == "test 0")
                {
                    lowH2WarningSystem.Enabled = false;
                }
                else if (words[0] == "transmit")
                {
                    string message = argument.Substring("transmit ".Length);
                    Echo("Transmitting: " + message);
                    antenna.TransmitMessage(message);
                }
            }
        }
Beispiel #3
0
 private void init()
 {
     antenna.Enabled = true;
     if (antenna.TransmitMessage("Init message", MyTransmitTarget.Owned))
     {
         parent.Echo("Com System online");
         ComWorking = true;
     }
     else
     {
         parent.Echo("Com System failure");
         return;
     }
     pointer   = 0;
     rnd       = new Random(antenna.CustomNameWithFaction.GetHashCode());
     currentID = (int)(rnd.NextDouble() * rnd.Next());
 }
Beispiel #4
0
        /* * * * * * * * * *
        * Main & Commands *
        * * * * * * * * * */

        public void Main(string argument, UpdateType updateSource)
        {
            //shit run every tick
            if ((updateSource & UpdateType.Update1) != 0)
            {
                //if we use the elevator
                if (useElevator && stations != null && stations.Count != 0)
                {
                    for (int i = 0; i < stations.Count; i++)
                    {
                        if (stations[i].Update())
                        {
                            broadcasts.Enqueue("request " + stations[i].name);
                        }
                    }
                }
            }

            //shit with arguments
            if ((updateSource & (UpdateType.Antenna | UpdateType.Trigger | UpdateType.Terminal)) != 0)
            {
                //if arguments are actually given
                if (cline.TryParse(argument))
                {
                    Action cAction;

                    String command = cline.Argument(0);

                    if (command == null)
                    {
                        writeLog("No Command was given!");
                    }
                    else if (commands.TryGetValue(command, out cAction))
                    {
                        cAction();
                    }
                    else
                    {
                        writeLog("Unknown Command: " + command);
                    }
                }
            }

            //at the end of every run we transmit one of the queued messages
            if (antenna != null && broadcasts.Count > 0)
            {
                if (sendable)
                {
                    antenna.TransmitMessage(broadcasts.Dequeue());
                    sendable = false;
                }
                else
                {
                    sendable = true;
                }
            }
        }
Beispiel #5
0
        public void Main(string argument, UpdateType source)
        {
            if ((source & UpdateType.Terminal) != 0)
            {
                string[] words = argument.Split(' ');

                if (words[0] == "transmit")
                {
                    antenna.TransmitMessage(argument.Substring("transmit ".Length));
                }
            }
        }
Beispiel #6
0
                public bool SendStringMessage(string message, MyTransmitTarget target = MyTransmitTarget.Default)
                {
                    if (type == antennaType.radioAntenna)
                    {
                        return(radioAntenna.TransmitMessage(message, target));
                    }
                    else
                    {
                        if (laserAntenna.Status == MyLaserAntennaStatus.Connected)
                        {
                            return(laserAntenna.TransmitMessage(message));
                        }
                    }

                    return(false);
                }
 private void IndividualSend()
 {
     if (isLaser)
     {
         if (lAntenna.TransmitMessage(msgQueue[0]))
         {
             msgQueue.RemoveAt(0);
         }
     }
     else
     {
         if (antenna.TransmitMessage(msgQueue[0], TRANSMITTARGET))
         {
             msgQueue.RemoveAt(0);
         }
     }
 }
Beispiel #8
0
        public void Main(string argument)
        {
            IMyRadioAntenna Radio = GridTerminalSystem.GetBlockWithName("Antenna") as IMyRadioAntenna;

            if (Radio is IMyRadioAntenna)
            {
                Echo(string.Format(@"Radio Found ""{0}"", IsFunctional:{1}, IsWorking:{2}, IsBroadcasting:{3}", Radio.CustomName, Radio.IsFunctional, Radio.IsWorking, Radio.IsBroadcasting));
                if (Radio.TransmitMessage(argument, MyTransmitTarget.Everyone))
                {
                    Echo(string.Format(@"sent ""{0}"" to everyone", argument));
                }
                else
                {
                    Echo("Can't send message");
                }
            }
            else
            {
                Echo("Radio not found");
            }
        }
Beispiel #9
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (goodsetup)
            {
                Echo("LastR: " + lastReversePath);
                Echo("Mode: " + mode);
                Echo("DockingDir: " + rcDockingDir.ToString());
                Echo("Password: "******"Argument: " + argument);
                    string[] info = argument.Split(new string[] { "," }, StringSplitOptions.None);

                    if (updateSource != UpdateType.Antenna)
                    {
                        if (info[0].ToLower() == "dock")
                        {
                            if (info.Length == 1)
                            {
                                Boolean sent = antenna.TransmitMessage("requestdock," + password + ",default");
                                if (!sent)
                                {
                                    messageQue.Add("requestdock," + password + ",default");
                                }
                            }
                            else if (info.Length == 2)
                            {
                                Boolean sent = antenna.TransmitMessage("requestdock," + password + "," + info[1]);
                                if (!sent)
                                {
                                    messageQue.Add("requestdock," + password + "," + info[1]);
                                }
                                groupName = info[1];
                            }
                            else if (info.Length == 3)
                            {
                                Boolean sent = antenna.TransmitMessage("requestdock," + password + "," + groupName + "," + info[2]);
                                if (!sent)
                                {
                                    messageQue.Add("requestdock," + password + "," + groupName + "," + info[2]);
                                }
                            }
                            else
                            {
                                Echo("ERROR, ARGUMENT SIZE INVALID");
                            }
                        }
                        else if (info[0].ToLower() == "stop")
                        {
                            Storage             = "";
                            dockingConnectorPos = new Vector3D();
                            dockingDir          = new Vector3D();
                            mode = 0;
                            globalPath.Clear();
                            reversePath.Clear();
                            rc.ClearWaypoints();

                            foreach (IMyThrust thrust in allThrusters)
                            {
                                thrust.ThrustOverridePercentage = 0;
                            }

                            foreach (IMyGyro gyro in gyros)
                            {
                                gyro.GyroOverride = false;
                                gyro.Pitch        = 0;
                                gyro.Yaw          = 0;
                                gyro.Roll         = 0;
                            }

                            Boolean sent = antenna.TransmitMessage("canceldock," + password);
                            if (!sent)
                            {
                                messageQue.Add("canceldock," + password);
                            }
                        }

                        else if (info[0] == "depart")
                        {
                            if (mode == 5 && connector.Status == MyShipConnectorStatus.Connected)
                            {
                                Main("dock," + groupName + ",leaving", UpdateType.Mod);
                            }
                            else
                            {
                                Echo("ERROR, WRONG MODE OR ALREADY DISCONNECTED");
                            }
                        }

                        else if (info[0].ToLower() == "newpassword")
                        {
                            Random r = new Random();
                            password = r.Next(1000000, 9999999) + "";
                        }
                    }

                    else if (updateSource == UpdateType.Antenna && info[0] == password)
                    {
                        Echo("Message Received: " + argument);
                        if (info[1] == "received" && info.Length == 3) //info[2] is name of spaceport
                        {
                            Echo("Request to '" + info[2] + "' was received, awaiting further instruction.");
                        }
                        else if (info[1] == "fail")
                        {
                            Echo("Request to '" + info[3] + "' failed.");
                        }
                        else if (info[1] == "rejected")
                        {
                            Echo("TOOK TO LONG, DOCKING PERMISSION REJECTED");
                            mode = 0;
                            rc.SetAutoPilotEnabled(false);
                            antenna.CustomName += " ERROR";
                        }
                        else if (info[1] == "wait")
                        {
                            Echo("Request to '" + info[3] + "' success, but placed into waiting que");
                            waiting = true;
                        }
                        else if (info[1] == "dockinginfo")
                        {
                            if (mode == 5)
                            {
                                connector.Disconnect();
                                List <MyWaypointInfo> path = new List <MyWaypointInfo>();
                                string[] strWaypoints      = new string[info.Length - 5];

                                for (int i = 0; i < strWaypoints.Length; i++)
                                {
                                    strWaypoints[i] = info[i + 5];
                                }

                                foreach (string waypoint in strWaypoints)
                                {
                                    MyWaypointInfo newPoint;
                                    Boolean        pass = MyWaypointInfo.TryParse(waypoint, out newPoint);
                                    if (pass)
                                    {
                                        path.Add(newPoint);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                                path.Reverse();
                                reversePath = path;
                                EnableRC(reversePath, out path);
                                mode = 6;
                            }
                            else if (info.Length == 5)
                            {
                                linkedConnectorName = info[2];
                                string strConnectorPos = info[3];
                                string strDockingDir   = info[4];

                                //parse str's into their proper values
                                Boolean pass1 = Vector3D.TryParse(strConnectorPos, out dockingConnectorPos);
                                Boolean pass2 = Vector3D.TryParse(strDockingDir, out dockingDir);

                                Dock2(dockingConnectorPos, dockingDir); mode = 2;
                            }
                            else if (info.Length > 5)
                            {
                                linkedConnectorName = info[2];
                                string   strConnectorPos = info[3];
                                string   strDockingDir   = info[4];
                                string[] strWaypoints    = new string[info.Length - 5];
                                for (int i = 0; i < strWaypoints.Length; i++)
                                {
                                    strWaypoints[i] = info[i + 5];
                                }

                                //parse str's into their proper values
                                Boolean pass1 = Vector3D.TryParse(strConnectorPos, out dockingConnectorPos);
                                Boolean pass2 = Vector3D.TryParse(strDockingDir, out dockingDir);
                                pass2 = false;

                                List <MyWaypointInfo> path = new List <MyWaypointInfo>();
                                Boolean pass3 = true;
                                foreach (string waypoint in strWaypoints)
                                {
                                    pass2 = true;
                                    MyWaypointInfo newPoint;
                                    pass3 = MyWaypointInfo.TryParse(waypoint, out newPoint);
                                    if (pass3)
                                    {
                                        path.Add(newPoint);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                                if (pass1 && pass2 && pass3)
                                {
                                    EnableRC(path, out globalPath);
                                    reversePath.Reverse();
                                    mode = 1;
                                }
                                else
                                {
                                    Echo(pass1 + " " + pass2 + " " + pass3);
                                }
                            }
                        }
                    }
                    else if (info[0] == "antennapos" && info.Length == 2)
                    {
                        Boolean updated = Vector3D.TryParse(info[1], out antennaPos);
                        if (updated)
                        {
                            antenna.Radius = (float)(Vector3D.Distance(rc.GetPosition(), antennaPos) + 10);
                        }
                        else
                        {
                            Echo("Failed to update antenna position");
                        }
                    }
                    else if (mode == 2 && !rc.IsAutoPilotEnabled && Vector3D.Distance(rc.GetPosition(), rc.CurrentWaypoint.Coords) >= 5)
                    {
                        rc.SetAutoPilotEnabled(true);
                    }
                    else if (mode == 1 && globalPath.Count != 0)
                    {
                        FollowPath(globalPath, true);
                    }
                }
                else if (mode == 1)
                {
                    FollowPath(globalPath, true);
                }
                else if (mode == 2 && rc.IsAutoPilotEnabled && Vector3D.Distance(rc.GetPosition(), rc.CurrentWaypoint.Coords) < 5)
                {
                    Dock3();
                    Boolean sent = antenna.TransmitMessage("freepath," + groupName);
                    if (!sent)
                    {
                        messageQue.Add("freepath," + groupName);
                    }
                }
                else if (mode == 2 && !rc.IsAutoPilotEnabled && Vector3D.Distance(rc.GetPosition(), rc.CurrentWaypoint.Coords) >= 5)
                {
                    rc.SetAutoPilotEnabled(true);
                }
                else if (mode == 3 && Dock3())
                {
                    Echo("DOCKED!");
                }
                else if (mode == 6)
                {
                    FollowPath(reversePath, false);
                }
                else if (updateSource == UpdateType.Update100)
                {
                    shipMass = rc.CalculateShipMass().TotalMass;
                }

                if (waiting)
                {
                    Echo("Waiting for clearance");
                }
            }
            else
            {
                Echo("SETUP FAILED. DO NOT SETUP WHILE CONNECTED TO ANOTHER GRID");
            }
        }
Beispiel #10
0
        public void antennaStuff(string shipIP)
        {
            IMyRadioAntenna antenna = GridTerminalSystem.GetBlockWithName("DefaultAntenna") as IMyRadioAntenna;

            antenna.TransmitMessage("MSG:CMD;Rec:1.2.3.4.UID;Snd:" + shipIP + ";RCT'MV'RemoteControl'GPS:Loc1:x:y:z;");
        }
        /* * * * * * * * * * *
        * Main and Commands *
        * * * * * * * * * * */

        public void Main(string argument, UpdateType updateSource)
        {
            /* When the game restarts it loads and executes the programmable block before it loads subgrids
             * this may lead to the script not finding blocks in subgrids in the constructor. Therefore,
             * the initialization of blocklists is done at the next tick, when the pb updates with updateType.Once */
            //TODO: do this without the check in main. maybe a command?
            if ((updateSource & UpdateType.Once) != 0)
            {
                init();
            }

            //This ensures that the script will only run if it was either started manually or triggered itself
            if ((updateSource & (UpdateType.Update1 | UpdateType.Update10 | UpdateType.Update100)) != 0)
            {
                //only if someone is actually seated, otherwise nothing is done
                if (controller != null && controller.IsUnderControl)
                {
                    if (Runtime.UpdateFrequency != seated)
                    {
                        Runtime.UpdateFrequency = seated;
                    }

                    float   y           = controller.MoveIndicator.Y;                    //PlayerInput [ SPACE ] and [ C ]
                    float   z           = controller.MoveIndicator.Z;                    //PlayerInput [ W ] and [ S ]
                    Vector3 forward     = controller.WorldMatrix.Forward;                //Normalized Vector forward relative to cockpit
                    Vector3 upward      = controller.WorldMatrix.Up;                     //Normalized Vector upward relative to cockpit
                    Vector3 velocities  = controller.GetShipVelocities().LinearVelocity; //Momentum-Vector of the cockpit
                    float   signedSpeed = forward.Dot(velocities);                       //normal projection of the speed vector onto the forward vector to get a signed speed value

                    //handling brake lights

                    /* The y value changes to 1 or -1 on a keyboard.
                     * Unfortunatly, on a hosted singleplayer at least, the client- and the server-values are swapped.
                     * The Server-Player will cause this value to read 1, clients will cause it to read -1.
                     * It somehow still works with -1, but not all the time. Just checking if it changed at all
                     * causes the lights to light up when pressing [ C ] as well, but this "bug" is deliberatly
                     * accepted to guarantee functionality of the brake-lights when pressing [ SPACE ] */
                    if (brake != null)
                    {
                        if ((y != 0) || (signedSpeed > 1 && z > 0) || (signedSpeed < -1 && z < 0)) //braking
                        {
                            if (!brakesOn)
                            {
                                for (int i = 0; i < brake.Count; i++)
                                {
                                    brake[i].Color = brakeOnColor;
                                }
                                brakesOn = true;
                            }
                        }
                        else
                        {
                            if (brakesOn)
                            {
                                for (int i = 0; i < brake.Count; i++)
                                {
                                    brake[i].Color = brakeOffColor;
                                }
                                brakesOn = false;
                            }
                        }
                    }

                    //handling reverse lights
                    if (reverse != null)
                    {
                        if (reverseManual || signedSpeed < -0.1)   //reversing
                        {
                            if (!reverseOn)
                            {
                                for (int i = 0; i < reverse.Count; i++)
                                {
                                    reverse[i].Enabled = true;
                                }
                                reverseOn = true;
                            }
                        }
                        else
                        {
                            if (reverseOn)
                            {
                                for (int i = 0; i < reverse.Count; i++)
                                {
                                    reverse[i].Enabled = false;
                                }
                                reverseOn = false;
                            }
                        }
                    }

                    //handling spotlights
                    if (spotlights != null && !spotlightsOn)     //turning on the lights
                    {
                        for (int i = 0; i < spotlights.Count; i++)
                        {
                            spotlights[i].Enabled = true;
                        }
                        spotlightsOn = true;
                    }

                    /*Set strength of dampeners:
                     *
                     * average the position of every wheel on its suspension when the car is not moving. add or remove strength until a desired value is reached
                     *
                     * position of the wheel can not be accessed directly (i think) so we need to compare the offset on the vertical axis inbetween them
                     *
                     * maybe even react to a moved center of mass
                     * */
                }
                else //if the cockpit is not under control..
                {
                    //..we are fine checking only every 100 ticks instead of every tick
                    if (Runtime.UpdateFrequency != UpdateFrequency.Update100)
                    {
                        Runtime.UpdateFrequency = UpdateFrequency.Update100;
                    }
                    if (controller.HandBrake != true)
                    {
                        controller.HandBrake = true;
                    }
                    if (spotlights != null && spotlightsOn)
                    {
                        for (int i = 0; i < spotlights.Count; i++)
                        {
                            spotlights[i].Enabled = false;
                        }
                        spotlightsOn = false;
                    }
                }
                //just to monitor performance
                Echo("LastRunTimeMS: " + Runtime.LastRunTimeMs.ToString("0.000000") +
                     "\nCurrent Instruction Count: " + Runtime.CurrentInstructionCount);
            }

            if ((updateSource & (UpdateType.Trigger | UpdateType.Terminal)) != 0)
            {
                //if a command is set
                switch (argument.ToLower())
                {
                case "switch garage":
                    antenna.TransmitMessage("open garage " + Me.CubeGrid.CustomName.ToLower());
                    Me.CustomData += "\nopen garage " + Me.CubeGrid.CustomName.ToLower();
                    break;

                case "switch reverse":
                    reverseManual = !reverseManual;
                    break;

                case "unlock":
                    disconnect();
                    break;

                case "lock":
                    connect();
                    break;
                }
            }
        }
Beispiel #12
0
        /* * * * * * * * * *
        * Main & Commands *
        * * * * * * * * * */
        public void Main(string argument, UpdateType updateSource)
        {
            try
            {
                //if a command is communicated to the script
                if ((updateSource & (UpdateType.Antenna | UpdateType.Trigger | UpdateType.Terminal)) != 0)
                {
                    //if arguments are actually given
                    if (cline.TryParse(argument))
                    {
                        String command     = cline.Argument(0).ToLower();
                        int    indexOffset = 0;
                        bool   meantForMe  = true;

                        //this could be handled more elegantly, but for readibility's sake it is done like this
                        if ((updateSource & UpdateType.Antenna) != 0 && command == "elevator" && cline.Argument(1).ToLower() == name)
                        {
                            indexOffset += 2;
                        }
                        else
                        {
                            meantForMe = false;
                        }
                        Action cAction;

                        //if the command was not sent via antenna and was meant for a different script
                        if (meantForMe)
                        {
                            switch (cline.Argument(0 + indexOffset).ToLower())
                            {
                            case "request":
                                if (cline.Count >= 2 + indexOffset)
                                {
                                    String requested = cline.Argument(1 + indexOffset);
                                    request(requested);
                                }
                                else
                                {
                                    writeLog("There was no station name or ID given!");
                                }
                                break;

                            case "addstation":
                                if (cline.Count >= 2 + indexOffset)
                                {
                                    Station toAdd;
                                    //GPS:NAME:36384:226384:5796384:
                                    //TODO write tryParseGps()
                                    if (tryParseGps(cline.Argument(1 + indexOffset, out toAdd)))
                                    {
                                        addStation(toAdd);
                                    }
                                    else
                                    {
                                        if (cline.Count >= 5 + indexOffset)
                                        {
                                            Vector3 toAddPos = new Vector3(float.Parse(cline.Argument(2 + indexOffset)),
                                                                           float.Parse(cline.Argument(3 + indexOffset)),
                                                                           float.Parse(cline.Argument(4 + indexOffset)));
                                            toAdd = new Station(toAddPos, ++lastID, cline.Argument(1 + indexOffset));
                                            addStation(toAdd);
                                        }
                                        else
                                        {
                                            writeLog("Station data could not be read");
                                        }
                                    }
                                }
                                else
                                {
                                    writeLog("There was no Station to add given");
                                }
                                break;

                            case "removestation":
                                removeStation();
                                break;

                            case "setmarker":
                                setMarker();
                                break;

                            case "debug":
                                debug = !debug;
                                break;

                            default:
                                writeLog("Unknown Command!");
                                break;
                            }
                        }
                    }
                }

                //if the elevator triggered itself
                if ((updateSource & (UpdateType.Update100 | UpdateType.Update1)) != 0)
                {
                    //raising the counter
                    if ((updateSource & UpdateType.Update1) != 0)
                    {
                        tickCounter++;
                    }
                    else
                    {
                        tickCounter += 100;
                    }

                    //after a set time window, check custom data for updates
                    if (tickCounter > 300)
                    {
                        //TODO: check wether or not this actually triggers and if the %= actually works
                        if (Me.CustomData != lastConfig)
                        {
                            loadCustomData();
                        }
                        tickCounter %= 300;
                    }

                    if (stopped)
                    {
                        //converting the single number given in seconds into comparable ticks
                        if ((DateTime.Now.Ticks - stopStamp.Ticks) > next.stopTime * 10000000)
                        {
                            stopped = false;
                            next    = null;
                        }
                    }
                    else  //if not stopped
                    {
                        //if there is a station we want to drive to
                        if (next != null)
                        {
                            //check the distance to the station we want to drive to and set velocities accordingly
                            //TODO: IN WHAT UNIT!?
                            float vertDist = next.getVectorFromPosition(Me.GetPosition()).Dot(forward) + next.offset;
                            if (direction)
                            {
                                //if we reached our station
                                if (vertDist < 0)
                                {
                                    stop();
                                }
                                else if (vertDist > brakeDist)
                                {
                                    upwards(1, (float)maxSpeed);
                                }
                                else
                                {
                                    float currentSpeed = getSpeed();
                                    float wantedSpeed  = Math.Max(vertDist * 10, 1);
                                    if (currentSpeed < wantedSpeed)
                                    {
                                        upwards(1, wantedSpeed);
                                    }
                                    else
                                    {
                                        downwards(1, currentSpeed - wantedSpeed);
                                    }
                                }
                            }
                            if (!direction)
                            {
                                if (vertDist > 0)
                                {
                                    stop();
                                }
                                else if (vertDist < -brakeDist)
                                {
                                    downwards(1, (float)maxSpeed);
                                }
                                else
                                {
                                    //we need to calculate with negative numbers, which looks a bit odd at first
                                    float currentSpeed = getSpeed();
                                    float wantedSpeed  = Math.Min(vertDist * 3, -1);
                                    if (currentSpeed > wantedSpeed)
                                    {
                                        downwards(1, wantedSpeed);
                                    }
                                    else
                                    {
                                        upwards(1, wantedSpeed - currentSpeed);
                                    }
                                }
                            }
                        }
                        else  //if there is no station we currently drive to
                        {
                            Station closestUp       = null;
                            Station closestDown     = null;
                            float   distClosestUp   = 0;
                            float   distClosestDown = 0;
                            //check for requested stations
                            for (int i = 0; i < stations.Count; i++)
                            {
                                //oh, found one!
                                if (stations[i].requested)
                                {
                                    float vertDist = stations[i].getVectorFromPosition(Me.GetPosition()).Dot(forward);
                                    if (vertDist > 1)
                                    {
                                        //only hold the closest ones, discard the rest
                                        if (closestUp == null)
                                        {
                                            closestUp     = stations[i];
                                            distClosestUp = vertDist;
                                        }
                                        else
                                        {
                                            if (vertDist < distClosestUp)
                                            {
                                                closestUp     = stations[i];
                                                distClosestUp = vertDist;
                                            }
                                        }
                                    }
                                    else if (vertDist < -1)
                                    {
                                        //only hold the closest ones, discard the rest
                                        if (closestDown == null)
                                        {
                                            closestDown     = stations[i];
                                            distClosestDown = vertDist;
                                        }
                                        else
                                        {
                                            if (vertDist > distClosestDown)
                                            {
                                                closestDown     = stations[i];
                                                distClosestDown = vertDist;
                                            }
                                        }
                                    }
                                    //if a requested station is not more than 1m away it will be the station we are currently stopped in.
                                    //the elevator should not move in this case, just open the door of the station
                                    //maybe the player was afk and forgot to leave on time?
                                    else
                                    {
                                        antenna.TransmitMessage("open station " + stations[i].name);
                                        stations[i].requested = false;
                                    }
                                }
                            }
                            if (direction)
                            {
                                //if there are further stations requested in the direction we are heading
                                if (closestUp != null)
                                {
                                    next = closestUp;
                                }
                                //if there are no more stations in the direction we are currently heading
                                else if (closestDown != null)
                                {
                                    next      = closestDown;
                                    direction = false;
                                }
                                //if there are no more stations requested at all
                                else
                                {
                                    Runtime.UpdateFrequency = UpdateFrequency.None;
                                }
                            }
                            else
                            {
                                //if there are further stations requested in the direction we are heading
                                if (closestDown != null)
                                {
                                    next = closestDown;
                                }
                                //if there are no more stations in the direction we are currently heading
                                else if (closestUp != null)
                                {
                                    next      = closestUp;
                                    direction = true;
                                }
                                //if there are no more stations requested at all
                                else
                                {
                                    Runtime.UpdateFrequency = UpdateFrequency.None;
                                }
                            }
                        }
                    }
                }

                printScreens();

                if (debug)
                {
                    printDebugScreen();
                }

                //printing a little manual into the echo part
                if (!debug)
                {
                    writeLog("    COMMANDS" +
                             "\nrequest STATIONNAME: tells the machine to go to this station" +
                             "\naddStation NAME X Y Z: adds the station with the given name and position to the elevator stations" +
                             "\nremoveStation NAMEID: removes the station with the given name from the elevator stations", true);
                }
            } catch (Exception e)
            {
                writeLog(e.Message + "\n" + e.StackTrace, true);
            }
        }