Space Engineers

Space Engineers

83 ratings
Khjin's Navigation Autopilot Script
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
7.046 KB
1 Apr, 2018 @ 8:39am
7 Apr, 2018 @ 8:52pm
4 Change Notes ( view )

Subscribe to download
Khjin's Navigation Autopilot Script

Description


=================================
NAS v1.1 Update is Live!

What's New?

- Mode Actions
- PlaySound command
- More accurate landings and hover
- Script Display
- Script optimizations

Check out the sections for details. Remember to refresh you scripts and re-apply NAS to the programmable block to apply the update. Thanks!

=================================

Hi there! Khjin (k-jin) here. Sorry for the username, it has been my go to for the longest time since I enter it and 99% of the time it has no duplicates. Anyways, you can call me 'K' or Jin if it makes it easier. :)

Alright on with the script!

About the Script

Navigation Autopilot Script or N.A.S is a script designed to perform the common tasks I do with my ships (cruising, landing, hover-bombing/hover drops, night cover mode and going back and forth the same place over and over again). The script works great with atmospheric ships but I plan to add more features to support space ships. I designed this script to work without the need for any markings to follow (for example when landing or hovering).

I mainly play within atmosphere so this script has been very handy for me in survival.

Script Setup

Here's how to setup NAS:

1. Add a programmable block to your ship and add this script. No need to use a timer.
2. Add or make sure your ship has at least one of the following **blocks:
  • 1 forward facing camera with "FCAM" anywhere in its name
  • 1 downward facing camera with "DCAM" anywhere in its name
  • 1 remote control. I suggest you put it in the middle of the ship or vertically in line with a bottom connector if your ship has one. No need to put in the center of mass.
  • 1 sensor. This should be at the bottom of the ship for maximum range (CoverMode).

3. Group the blocks and put "NAS" anywhere in the group name.
4. Compile the script and remember and exit. Done!

**Note: You can have multiple of the mentioned blocks for redundancy.

Using Script Commands [NEW!]

To use the different features of the script, add the following run action for the NAS programmable block:
  • Run "covermode" to activate CoverMode
  • Run "hovermode" to activate HoverMode
  • Run "cruisemode" to activate CruiseMode
  • Run "autolandmode" to activate AutolandMode
  • Run "pin" to pin current location
  • Run "usepinned_onoff" to toggle using pin for HoverMode or AutolandMode
  • Run "playsound:<Sound Block Name>:<Sound Name>" to play sound
    Example:
    playsound:Sound Block 1:Alert 1

Script Features

Now what can this script do?
  1. CruiseMode. The script will try to maintain a set forward cruising speed. I use this feature a lot for my mining ships during long trips or when exploring.

  2. AutolandMode. By default, the script will use the DCAM (no need to view) to calculate the landing spot directly below your ship and then land. If you wish to land to a specific spot, you can View any of the cameras included in the NAS group, aim to the desired landing spot and run the "autolandmode" command. When using a custom landing spot, the ship will first climb to a set elevation before landing. I use this when landing at night since I'm using mods that increase darkness. You can also use this to do stealth missions where you can't use any lighting.

  3. HoverMode. By default, this script will use the FCAM (no need to view) to calculate the hovering spot. Just aim the camera to where you want to hover and run the "hovermode" command. If you wish to hover to a specific spot, you can View any of the cameras included in the NAS group, aim to the desired hovering spot before running the command. I use this a lot when I want accurate supply drops (or bomb drops hehehe).

  4. CoverMode. This feature uses a sensor attached at the bottom of your ship to try and find you and then follow you or any large or small ship you are in from a certain height. Given the limited range of vanilla sensors, this feature only works within 45 meters around the sensor. You may use a modded one to extend the range. Ships using CoverMode takes time to react to movement so this feature is only useful for covering characters (even running) or slow moving ships but this can be improved with a modded sensor. I use this mainly for night light drones or when retrieving unknown signals (sometimes I don't land, I just jump from my ship so the light is handy).

  5. Pin. Using this feature will make the script remember the current location of the ship, or more specifically the remote control block.

  6. UsePinned_OnOff. When turned ON, the ship will use the pinned location during AutoLandMode or HoverMode.

Important: You can stop the current mode at any time by running the same command or running a different command twice. I suggest using CruiseMode as a quick way to stop the running mode since it doesn't use any remote autopilot.

Mode Actions [NEW!]

Have you ever thought, "If only this script allows me to do something else when a mode is changed". Yes? No? Well, I did. I wanted the script to say a cool "Cruising mode enabled". I wanted the ship to fold out landing gears when auto-landing and lock them when I landed. Or as one of my commentators said, I want my ship to hover to a target, bombard it with rockets and go back to the pinned position.

But doing that will bloat my ship with a lot of timer blocks or new scripts. Not anymore!

With mode action, you can customize what the ship will do when a certain mode is activated. To do this, add an action to the Custom Data of the programmable block:

<block name or group name>:<on|during|after>:<mode>:<action name>:<data>

Example:

Landing Gears:after:autolandmode:Lock:
Sound Block:on:cruisemode:PlaySound:Cruise Mode Activated

After this, run "initialize" on the programmable block. Done!

Note: As of NAS v1.1, only PlaySound action supports the <data> part of the mode action.
I will add more custom actions in the future.

Checking Script Status [NEW!]

The script needs a more customized and faster way of displaying the current status so I decided to allow the script to output status on it's own. To do this just add an LCD (at least 1x1 size) to the "NAS" group and done, status display!

Customizing the Script

The script contains a couple of configurable settings to customize the script for your ship. Kindly check these settings especially the LANDING_HEIGHT for more accurate landings.

Planned Features

I have a couple of things in mind that I plan to add to the script so stay tuned!

Collision detection for CruiseMode.
Customizable mode completion actions (like locking landing gear after landing)
AutoLandMode in space stations.
Follow mode
NAS' own status display on LCD (faster updates)
Docking sequence recorder
Support for multiple "pinned" locations


Thank you so much guys for checking out this script. I hope this makes your gameplay more convenient and safe. If you like the script, give it a thumbs up and fav it for updates. If you have any questions, suggestions, or feature request, leave a comment and I'll try my best to add it.

Until then, fly safe and keep building! :)
Popular Discussions View All (2)
3
8 Apr, 2018 @ 4:35pm
Inspiration
CTH2004
0
27 Feb, 2021 @ 10:54am
Changes required to make LCDs work again
Stubkan
33 Comments
Quickshadow10m 9 Apr, 2020 @ 7:29pm 
thx, you should rewrite the script, maybe add a function for turret tracking in covermode instead of senser, because I was able to use agility IN WALK MODE to get out of senser range at 35m height. I feel that this script has so much potential that is lost if you use 'Just the ingame autopilot', Maybe a system that uses raycast to avoid objects and to land safely even if there are objects near the pad to avoid. Some good scripts you could use for a refrence is PAM or SAMv2. I love especially PAM (As I have not tried SAMv2) because of the docking sequence alone. Untill next time, I hope you keep on trucking, you are a incredibly good scripter, with great potential to be up there next to Radv, Whiplash141, Kek.

-Quickshadow10m
Khjin  [author] 9 Apr, 2020 @ 7:06pm 
Hahaha sorry about that, I haven't done much about the script lately. I'm actually surprised it still works as AI seems to be a bit buggy for me. Anyways, you can connect to the ship remotely via antenna then run "covermode" on the PB and it will stop cover mode. Better yet, you can run "autolandmode" to have the ship land instead of it running from you. Hope this helps :steamhappy:
Quickshadow10m 8 Apr, 2020 @ 12:34pm 
Hey, is there a way I can stop it trying to cover me? I try to get back in the ship, but it just flies up farther away.
Khjin  [author] 13 Mar, 2020 @ 8:20am 
Cruise mode tries to keep the ship at a set speed forward, only firing thrusters when needed. You need to do the alignment manually. In a way, it saves fuel by using as little thrust as needed.
Booperius 11 Mar, 2020 @ 11:18pm 
Does cruisemode work on planets i.e does it constantly accelerate in a gravity well or does it let things "coast" to conserve fuel?
Khjin  [author] 6 Aug, 2019 @ 7:21am 
I'd love to but the blueprint I used in the screenshots got wiped when my old pc died :steamfacepalm:. I'll make a new ship instead and post it. :steamhappy:
TheFirstAnon 4 Aug, 2019 @ 3:59pm 
Could you upload the blueprints for the ship in the thumbnails?
Khjin  [author] 2 Aug, 2019 @ 11:29am 
@Najuel Hello! I'm good, just a bit busy in life. :D

Anyways, that is not really a problem. It's just the script calling some old code but it still works. I will update the script but not anytime soon. Tbh this script needs an overhaul at this point :steamfacepalm:
Najuel 29 Jul, 2019 @ 7:22pm 
Hi, how are you?, i get the following message:
Program(1026,57): Warning: 'IMiTextPanel.GetPublicText()' is obsolete: LCD public text is deprecated
Program(1028,58) Warning about IMyTextPanel.WritePublicText(string,bool) is obsolete
Program(1029,12) Warning about IMyTextPanel.ShowPublicTextOnScreen() is obsolete
Program(1026,57) Warning IMyTextPanel.Get PublicText() is obsolete
Program(1028,58) Warning IMyTextPanel.WrhitePublicText(...) is obsolete
Program(1029,12) Warning IMyTextPanel.ShowPublicTextOnScreen() is obsolete
Khjin  [author] 18 Jun, 2019 @ 8:44am 
@Nizzine Hello! It would be great if you can describe the problem a bit more. But if you want a quick fix, you can try and make sure all parts including the sensor and the text panel is added to the NAS group. Usually that's enough. :)