Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Remote Control Commands, please help!

Discussion in 'Programming (In-game)' started by ElBordelo, May 24, 2017.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. ElBordelo Trainee Engineer

    Messages:
    19
    Hi, please can someone give me an example of a scipt with:

    Set up remote control´s block Precision Mode_On,
    Set Flight Mode to One Way,
    and set up Forward Direction to e.g. Forward?

    I can´t find appropriate commands anywhere.
    And some simple script how to align text to the middle of LCD Panel please?
    Thank you.
     
  2. Georgik Apprentice Engineer

    Messages:
    215
    By now it's:
    So I will take it from the least difficult one.
    Code:
    	var rc = GridTerminalSystem.GetBlockWithName("Remote Control") as IMyRemoteControl;
    	rc.ApplyAction("Backward"); // Set remote direction. Can be: "Forward" "Backward" "Left" "Right" "Up" "Down"
    //OR
    	rc.SetValue<long>("Direction", 1); // where number is number of item in combobox starting with 0. (Down = 5)
    //===========================================
    	rc.ApplyAction("DockingMode_On"); // Activate Precision mode.
    //OR
    	rc.SetValueBool("DockingMode", true);
    //===========================================
    	rc.SetValue<long>("FlightMode", 2); // Sets Flight mode to "One way". 2 is index of "One way" in combobox. (0 = Patrol, 1 = Circle)
    
    //===========================================
    //EDIT: added collision avoidance
    	rc.ApplyAction("CollisionAvoidance_Off"); // Disable Collision avoidance.
    //OR
    	rc.SetValueBool("CollisionAvoidance", false);
    
    Hope it will help.
     
    Last edited: Jun 6, 2017
    • Informative Informative x 2
  3. ElBordelo Trainee Engineer

    Messages:
    19
    Perfect, that is exactly what I needed. :)
    I was close with FlightMode, but I tried rc.SetValue<int>("FlightMode", 2);
     
  4. Ronin1973 Master Engineer

    Messages:
    4,955
    Also, consider the Collision Avoidance properties (On or Off). When you're trying to dock with another ship, it needs to be off else the auto pilot will try to avoid the target ship.
     
  5. Georgik Apprentice Engineer

    Messages:
    215
    That is almost the same, but for sake of completeness I added it to the code. :)
     
  6. Sero93 Trainee Engineer

    Messages:
    47
  7. Georgik Apprentice Engineer

    Messages:
    215
    This site is out-dated, many properties are missing.
     
  8. Teddy Trainee Engineer

    Messages:
    3
    Hi and sorry for resurrecting this old thread.

    I try to set the FlightMode on a RemoteBlock from a ProgrammableBlock like the example above shows.
    Code:
    remote.SetValue<long>("FlightMode", 2);
    But i get the exception "Invalid property at Sandbox.ModAPI.Interfaces.TerminalPropertyExtensions.Cast[TValue](ITerminalProperty property)".
    Any idea whats wrong?

    Best regards
    Teddy
     
  9. plaYer2k Master Engineer

    Messages:
    3,160
    Most old Keen-properties do have proper C# properties now and thus you can use these.
    Code:
    namespace Sandbox.ModAPI.Ingame
    {
     public interface IMyRemoteControl : IMyShipController, IMyTerminalBlock, IMyCubeBlock, IMyEntity
     {
     /// <summary>
     /// Determines whether the autopilot is currently enabled.
     /// </summary>
     bool IsAutoPilotEnabled
     {
     get;
     }
     /// <summary>
     /// Gets or sets the autopilot speed limit
     /// </summary>
     float SpeedLimit
     {
     get;
     set;
     }
     /// <summary>
     /// Gets or sets the current flight mode
     /// </summary>
     FlightMode FlightMode
     {
     get;
     set;
     }
     /// <summary>
     /// Gets or sets the current flight direction
     /// </summary>
     Base6Directions.Direction Direction
     {
     get;
     set;
     }
     /// <summary>
     /// Gets the current target waypoint
     /// </summary>
     MyWaypointInfo CurrentWaypoint
     {
     get;
     }
     /// <summary>
     /// Gets the nearest player's position. Will only work if the remote control belongs to an NPC
     /// </summary>
     /// <param name="playerPosition"></param>
     /// <returns></returns>
     bool GetNearestPlayer(out Vector3D playerPosition);
     /// <summary>
     /// Removes all existing waypoints.
     /// </summary>
     void ClearWaypoints();
     /// <summary>
     /// Gets basic information about the currently configured waypoints.
     /// </summary>
     /// <param name="waypoints"></param>
     void GetWaypointInfo(List<MyWaypointInfo> waypoints);
     /// <summary>
     /// Adds a new waypoint.
     /// </summary>
     /// <param name="coords"></param>
     /// <param name="name"></param>
     void AddWaypoint(Vector3D coords, string name);
     /// <summary>
     /// Adds a new waypoint.
     /// </summary>
     /// <param name="coords"></param>
     void AddWaypoint(MyWaypointInfo coords);
     /// <summary>
     /// Enables or disables the autopilot.
     /// </summary>
     /// <param name="enabled"></param>
     void SetAutoPilotEnabled(bool enabled);
     /// <summary>
     /// Enables or disables collision avoidance.
     /// </summary>
     /// <param name="enabled"></param>
     void SetCollisionAvoidance(bool enabled);
     /// <summary>
     /// Enables or disables docking mode.
     /// </summary>
     /// <param name="enabled"></param>
     void SetDockingMode(bool enabled);
     }
    }
    
    namespace Sandbox.ModAPI.Ingame
    {
     public enum FlightMode
     {
     Patrol,
     Circle,
     OneWay
     }
    }
    
    I hope that this helps.
     
  10. Teddy Trainee Engineer

    Messages:
    3
    Oh yes, that helped!
    Thanks a lot :)
     
Thread Status:
This last post in this thread was made more than 31 days old.