Space Engineers

Space Engineers

Cruise Control
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.
ZerothAngel  [author] 29 Mar, 2024 @ 11:14pm 
Try creating a group called CruiseControlGroup around only the thrusters you want the script to control. Then re-compile the script and try again.
Sanguin 29 Mar, 2024 @ 10:25am 
i used "cruise 1 right i" it uses my ions and my modded hydro thruster which i am figuring is the issue. If so is there a way to make it not detect that thruster anymore?
ZerothAngel  [author] 28 Mar, 2024 @ 3:14pm 
@Sanguin Hey, just tested it out and it seems to work. Can you give an example of a command you used that didn't work as expected?

I used something like "cruise 10 forward h" and it correctly only used hydrogen thrusters to cruise forward.
Sanguin 25 Mar, 2024 @ 4:37pm 
Howdy, I am enjoying your script but i cant get the thruster specification to work properly. i have added the type to command but it still uses all thruster types.
hanels 20 Nov, 2023 @ 3:44pm 
It did this problem only on one grid. On the second one it worked well. I rewrite script and now it works ;)
ZerothAngel  [author] 20 Nov, 2023 @ 10:46am 
@hanels What are some of the error messages? I just tried it out and it seems to work/compile fine.
hanels 19 Nov, 2023 @ 5:14pm 
I use this script for my trains. On all cars. Without any problem. But now I build new train and somehow it doesnt work :/ it calls some errors when recompile
GOODYOB 25 Jun, 2023 @ 5:31am 
for some reason script doesn't accelerate the grid when I use a control seat, helm specifically
as soon as I leave it the grid starts accelerating to a set speed
ZerothAngel  [author] 19 Jun, 2023 @ 5:37pm 
You shouldn't have to. When setting the reference block, this script will look at all the blocks in CruiseControlReference (which may include blocks from multiple grids) and it will only accept & use the first block it finds on the same grid as its PB.

(So while my generic library doesn't care about grids, the layer above it, i.e. this script, does make sure the blocks it touches are local.)
Battlemage 19 Jun, 2023 @ 5:27pm 
You rock. Everything is working just fine now. I'm assuming that since I'm using this in an automated shuttle, if I have multiple shuttles going at the same time I'll have to rename the CruiseControlReference group to be unique on each shuttle?
ZerothAngel  [author] 19 Jun, 2023 @ 3:52pm 
Script updated.
ZerothAngel  [author] 19 Jun, 2023 @ 3:10pm 
The exception is coming from my generic library, which doesn't care about grids.

I guess the "duplicate" group doesn't necessarily have to be CruiseControlReference to cause the exception. The library function is trying to gather all the available groups, and a group on the shuttle "collides" with one on your local grid.

The game is case-sensitive when it comes to groups, so I guess my scripts will have to be as well. That will be an annoying change.

Thanks for the bug report.
Battlemage 19 Jun, 2023 @ 8:07am 
There's only one CruiseControlReference group on the local grid, and none on grids attached via connectors. The script thows an exception only when my shuttle is docked to my main grid - if I turn off the connector to undock then recompile the PB, the script functions again. Seems that something on the remote grid is causing the script to crash, but it shouldn't even be looking at those grids, should it?
ZerothAngel  [author] 18 Jun, 2023 @ 11:00pm 
I can't try out the game right now, but check the letter case in your CruiseControlReference group. Might you have more than 1 group with that name that differs by letter case?

I'm not sure if the game actually allows distinct groups with the same name that only differ by letter case, but that's the only thing that makes sense with that error.

I'll have to eventually investigate (and fix on my side, if needed), but making sure there are no duplicate CruiseControlReference groups should avoid the issue you're seeing.
Battlemage 18 Jun, 2023 @ 6:15pm 
Lately I've been running into an issue where the script is throwing errors when I try to run it. Any ideas?

[code]Caught exception during execution of script:An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Program.ZACommons.get_GroupsByName()
at Program.ZACommons.GetBlockGroupWithName(String name)
at Program.ShipOrientation.SetShipReference(ZACommons commons, String groupName, Func`2 condition)
at Program.Main(String argument, UpdateType updateType)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.<>c__DisplayClass42_0.<ExecuteCode>b__0(IMyGridProgram program)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.RunSandboxedProgramActionCore(Action`1 action, String& response)
[/code]
AlienXtream 26 Apr, 2023 @ 8:44pm 
atmospheric physics mod or whatever its called. so ships slow down from drag
ZerothAngel  [author] 26 Apr, 2023 @ 8:02pm 
Yes. It measures the ship's speed 30 times a second and adjusts the thrust to keep it within 2% of your set speed.

It works in vanilla, at least. Are you talking about atmospheric drag through some mod, or the usual decay of thrust of ion/atmo engines depending on your altitude?
AlienXtream 26 Apr, 2023 @ 7:19pm 
ok. so if the ship slows down in atmo it will throttle up to raise speed assuming i dont stop the script?
ZerothAngel  [author] 26 Apr, 2023 @ 6:30pm 
It should keep running until you send it a "cruise stop"
AlienXtream 26 Apr, 2023 @ 5:07pm 
does this reactivate if the speed drops by other means, say "air resistance"? or do i have to keep running the script to maintain speed in that circumstance?
Battlemage 16 Apr, 2023 @ 2:02pm 
By far the easiest to use cruise control script I've found on the workshop. Using this as the speed controller for my Hover Rail Automated Cargo Shuttle since nothing else on the workshop or vanilla could set and hold a designated speed on command like this script does. Thanks!
MIMI Sentry 20 Sep, 2022 @ 7:38pm 
@Wuzyx You either have subgrids that are causing drag (because Keen physics) or you are not leveling yourself out constantly. With how small planets are, even at max size, going the same speed won't stop you from aiming above or below the horizon.
Wuzyx 2 Sep, 2022 @ 10:44am 
Yo. I have this issue where when using the script on a atmosphere ship it's slowly losing altitude. Is it something I've set up wrong? (I know it's not too heavy, I've tested it)
EdrickV 17 May, 2022 @ 10:54pm 
Not sure what is going on, but it doesn't seem like the workshop version of the script is being downloaded properly, it doesn't show up when looking through the list of scripts installed or when searching. It used to work, and I've gotten a copy from a previous game, but it would be nice if whatever went wrong with this mod could be fixed.

The script itself has worked fine for me, it just seems like the workshop is messed up. And the github copy is gone.
Devfred 19 Feb, 2022 @ 10:31pm 
It appears that when I use the CruiseControlGroup group on some of my thrusters, the script doesn't appear to do anything when I instuct it to go in any direction. (As soon as I remove the CruiseControlGroup though the script works fine)

I'm specifically looking for only some of the thrusters to be used by the script though. Any thoughts as to why when I add thrusters to the CruiseControlGroup group the script doesn't appear to do anything?
Neptune 30 Dec, 2021 @ 9:19am 
Was the github taken down?
Malhavoc 16 Sep, 2021 @ 12:21pm 
Have attempted to load into programming block lately and have not had any success, anyone experiencing this issue
hanels 4 Apr, 2021 @ 5:18am 
Hello, your script is good and work well. I am using this scrip on my trains, but with some locomotives it shows error after connecting waggons. When I disconnect waggons there is still error and I must remove and place this locomotive again. Do you know this error?
KagedDaemon 10 Dec, 2020 @ 10:34am 
Would it be possible to get this added to the mod.io for us console peasents?
Kevin Starwaster 25 Sep, 2020 @ 11:17am 
Ok, tried JUST doing the reference group and that worked
Kevin Starwaster 25 Sep, 2020 @ 11:14am 
also having the issue where it thrusts in the wrong direction. I set it to forwards (cruise 25 forwards a) and it would instead activate the left thrusters.

I also added my cockpit to a CruiseControlReference group and only the two atmospheric thrusters I use for propulsion. After that, no thrusters would answer to the plugin

Also your GItHub does not lead to a copy of this script at all
Nighthunter 9 Sep, 2020 @ 7:43am 
@ZerothAngel allready tried that I get an expection error when I try that.
ZerothAngel  [author] 8 Sep, 2020 @ 7:37am 
Try grouping only the thrusters you want the script to control under a group named CruiseControlGroup

Not sure why it's not documented above, but that I see that feature is there in this version of the script.
Nighthunter 8 Sep, 2020 @ 3:16am 
@ZerothAngel Is there a way to have the script ignore certain thrusters, like two of 4 hydrogen thrusters for example?
B1487E 23 Mar, 2020 @ 7:24pm 
@Moqi, get into the cockpit that you want the script to reference, press "K" then make a group with just that cockpit called CruiseControlReference, then recompile the script. Hope that helps
Moqi 23 Mar, 2020 @ 6:44pm 
i don't know why all direction are wrong ... left go in front
right in back .... when i do cruise set in any direction it go right
but good script i just wanted a cruise for my tunel ship and its awesome :P
B1487E 29 Feb, 2020 @ 6:03pm 
Thanks for responding, I'll try that and see what happens
ZerothAngel  [author] 29 Feb, 2020 @ 5:27pm 
VapeGuy93 - I'm guessing no, the thruster type argument would not work for modded engines. The script is already using a hack (identifying the engine type by name) to distinguish thrusters and I'm not sure if there's been any improvements to the scripting API.

However, what might work is if you create a group named CruiseControlGroup around only the nuclear engines. And then don't use any sort of thruster spec.

Then again, first try it without doing anything and see if it can control them properly... The script classifies any engine without "Hydrogen" or "Atmospheric" in the type name as ion, so...
B1487E 29 Feb, 2020 @ 10:53am 
Does the thruster type argument work for mod engines? Im using the Nuclear Engines mod and I want this script to only use them.
Stan 4 Feb, 2020 @ 5:46am 
(also -- apologies if I sound blunt, had to edit down the message, again, due to the character limit; just be clear, still love your work! :D )