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
Khjin  [author] 8 Apr, 2018 @ 10:13am 
Thanks, I'm glad you like it :)
MistyBitty 8 Apr, 2018 @ 9:52am 
Amazing!! well done kind sir.. =D
CTH2004 5 Apr, 2018 @ 1:40pm 
@Khjin Fair Enough! Can't wait for whatevers next!
Khjin  [author] 5 Apr, 2018 @ 6:56am 
@CTH2004 I built the script to avoid crashing and not otherwise. However, I won't say anything if you decide to strap your ship with a lot of warheads, cruisemode to your target, and detonate the warheads with a sensor. :D
Khjin  [author] 5 Apr, 2018 @ 6:55am 
@The Meanie So far I have no plans for an "attack" mode, maybe at most a missile dodge assist? Anyways, you can always chain the commands to get a similar effect. Example, you can build a drone with rockets pointing downard, use hovermode to get to target and with a timer block, delay a rocket barrage. after that, also with a timer, you can call usepinned_onoff and autolandmode to make the drone go back to base.

Or, you can wait a bit for an update that will make that easier. :)
CTH2004 4 Apr, 2018 @ 5:21pm 
Um... there is one manuver you forgot! The CRASH Manuver! (Seriously, that would be perfect for a self destruct, or, once space support is in, a scenerio could have you start right abover a plantet, and on a timmer cause it to crash! You wouldn't think anything was up, until you're down!)

Thanks Khjin
The Meanie 4 Apr, 2018 @ 2:14pm 
Any chance for an attack mode? Like it tries to circle a point you aim at, or "Raid" it goes to a place, firing weapons on any detected enemies, and then returns to the sendoff location?

Also thank you a LOT for this script, it's the first time I've ever managed to make anything that can do a thing without me controlling it manually! :D
Khjin  [author] 3 Apr, 2018 @ 11:10am 
nvm, found your ship and fixed the CruiseMode problem. Enjoy :)
Khjin  [author] 3 Apr, 2018 @ 9:30am 
If you can link me a blueprint of your ship it would be a great help for me to figure out why CruiseMode is not doing what it's supposed to. Thanks!
remethep 3 Apr, 2018 @ 7:21am 
Happy to help out. :)