Space Engineers

Space Engineers

117 ratings
Cruise Control
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
412.382 KB
8 Aug, 2015 @ 2:47pm
19 Jun, 2023 @ 3:46pm
23 Change Notes ( view )

Subscribe to download
Cruise Control

Description
2017-11-17 Update: No longer needs a timer block. If you had one before, I recommend you "disconnect" it from the prog block (remove all its actions) to reduce surprises.

Cruise control for ships of any size. Fixes your speed at whatever speed you want, in any direction you want, using whatever combination of thruster types (ion, atmo, hydrogen).

How is this different than simply turning off inertial dampeners? Well, the main difference is that you can actually steer and it will automatically change directions. ;) Also, no need to hold down your forward thrust button for however long. (Great for large, slow ships!)

Setup

Just load it into a programmable block. No timer block required.

The Reference Block

If your grid axes are off (and you'll know, because you'll start moving in another direction besides forward), you need to set a reference group.

Select a block that is properly oriented with the "forward" and "up" directions of your ship, most likely a cockpit/flight seat/remote control etc. Create a group with this block named CruiseControlReference (note: case-sensitive!)

After creating the reference group, be sure to also re-compile the script.

Usage

You use the script by running it with certain arguments. So you would normally set these up on your cockpit/remote whatever toolbar (i.e. drag programmable block from 'G' menu to toolbar, select "Run", and when prompted for an argument, enter one of the following commands)

Note that some commands may take a "thruster specification." This allows you to specify which types of thrusters to affect. By default, all thruster types are used. The thruster-spec is simply a string with one or more of the following letters:
  • i -- For ion thrusters
  • a -- For atmospheric thrusters
  • h -- For hydrogen thrusters
Letter case and order doesn't matter. So "ah" and "ha" will use atmo & hydrogen thrusters. Also note that since Keen provides no way for scripts to determine the type of thruster (aside from name), this feature may not be usable when the game is not set to English.
  • cruise reset -- This will re-enable all thrusters, reset their thrust override to 0, and shut off the cruise control script if it is running.

  • cruise reset <thruster-spec> -- Similar to the previous, but will only touch the thruster types specified by <thruster-spec>. For example "cruise reset h" will stop the script and re-enable all hydrogen thrusters. The other thruster types are left alone.

  • cruise stop -- This shuts off the script and restores the state of all thrusters as they were before the first cruise command you issued since last stopping.

  • cruise <speed> -- Cruises forward. <speed> is some number representing the desired speed in meters per second. For example "cruise 25" or "cruise 104.4"

  • cruise <speed> <direction> -- Similar to the previous, but allows you to cruise in any direction. <direction> can be one of the following words: "forward" "forwards" "backward" "backwards" "up" "down" "left" "right"

    So "cruise 50 up" will cause your ship to thrust upwards at 50 m/s.

  • cruise <speed> <direction> <thruster-spec> -- Similar to the previous, but will only touch thruster types given by the <thruster-spec>. For example "cruise 25 forward ia" to cruise forward at 25 m/s using only ions + atmo. Note that in order to specify a thruster-spec, you must also specify a direction.

  • cruise reverse -- Similar to "cruise stop" but will also re-orient the ship so its rear is against the current direction of motion. Not recommended for use in a gravity well.

  • cruise set -- Activates cruise control using the ship's current speed (technically, it uses the magnitude of the ship's velocity... so keep this in mind if you're moving backwards, for example)
    Similarly, you can substitute the word "set" or "current" for <speed> in any of the commands above and it will use the ship's current speed.
Once your speed is "close enough," your thrusters along your direction of motion will be turned off. They will be activated again if you change directions or set a new speed.

LCD Output

See this post.

Source

For the bleeding edge, as well as a more readable and modular version of the script, go see GitHub[github.com]. I usually only update the workshop version when things break or major features are added.
Popular Discussions View All (2)
0
28 Jun, 2021 @ 12:35pm
[Possible Feature] Incremental Velocity Control
RillienCot
156 Comments
ticklemyiguana 12 Jan @ 1:52pm 
@ZerothAngel

Hey, just figured I'd share what I needed your script for. Thanks again.

https://youtu.be/Fjx7adXu1sE?si=lVCmWRdE7j07LnaJ
ticklemyiguana 31 Dec, 2024 @ 8:36pm 
@ZerothAngel

Thanks for getting back so quick. Didn't expect it and it went over my head. I'll keep fiddling with it. I have a 6.3 million kilometers ship with I think... 36 large ion thrusters for forward thrust and only a few small ones for docking and final maneuvers in every other direction. It very much needs a script like this, and it also needs to be abortable both for combat and for asteroids. I sure don't know what I'm doing with C# to make it work my way, so I think I'm going to have to just use a timer to turn off gyro override and turn on thrust and just let that slide mentally as "this is the emergency button, you'll have to do a hard reset."

Still, if you're still updating/working on this I'll keep checking back. Thanks again. This is the only script I can find that does something like this.
ZerothAngel  [author] 26 Dec, 2024 @ 12:42am 
@SnuggleBug Yeah, that's kind of a bug. If the script doesn't release control, the only thing you can do is re-compile/reset the PB.

But! It's not releasing control because it's trying to get your ship within .2 degrees of your original velocity before re-enabling all thrust. For some ships, this might be too narrow/too small of a tolerance.

Aside from slapping on more gyros, another thing to try:

1. Select the PB and edit its Custom Data
2. Add the following

cruiseMaxGyroError .05

3. Re-compile and try again. The number is the tolerance in radians. .05 radians is almost 3 degrees, which seems plenty tolerant.
ticklemyiguana 26 Dec, 2024 @ 12:21am 
Hey I'm having an issue where cruise stop and cruise reset simply don't work during a cruise reverse maneuver. If I disable gyro override and turn on the thrust to achieve the same result, it then requires a full recompile to function properly again.

Thanks very much for creating this, despite the issue.
ZerothAngel  [author] 6 Dec, 2024 @ 3:54am 
@iddqd Sure, it's public and up-to-date again.

At some point though, I started modding the game and adding my own Lua functions. I got tired of maintaining two branches of scripts (especially since they weren't public anymore in the first place). The scripts haven't been used in the vanilla game in a long while.
iddqd 6 Dec, 2024 @ 12:04am 
hey there, sorry for posting this on an unrelated workshop item but because you said you won't accept random friend requests I couldn't figure out a better place - is there any way to get a copy of your From the Depths Lua scripts github repository? it's seemingly gone now and I've recently gotten into the game and would love to have it as reference. thanks!
Sanguin 13 Apr, 2024 @ 7:44am 
Sorry for taking so long to reply. I tried using that group and it just made it so it would use the thrusters
PimpMyDog 9 Apr, 2024 @ 9:53pm 
Oops didn't notice the notification. Yep in the same grid. The cockpit is modded though but it still manually flies like it should and remote control block is vanilla. Oh well I'll just use "cruise down" to go forward. Not a dealbreaker, still a very useful script!!
ZerothAngel  [author] 2 Apr, 2024 @ 6:52pm 
@PimpMyDog Are the cockpit and remote on the same grid as the prog block? That's the only thing I can think of that would cause them to be ignored as a reference.
PimpMyDog 2 Apr, 2024 @ 2:19pm 
I have made reference groups with cockpit and a remote block but with either of them the script thinks upwards is forwards... I copy pasted the group name so no typos or case sensitivity inaccuracies there.