Space Engineers

Space Engineers

Not enough ratings
aveBrian's Trailer Control Script V2.0
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
383.966 KB
23 Apr, 2018 @ 9:35am
7 Aug, 2021 @ 8:07am
13 Change Notes ( view )

Subscribe to download
aveBrian's Trailer Control Script V2.0

Description
ATTENTION:

This is a massive update to the previous version of this script under the old title "TrailerControlScript(Thrusters)".

What Does It Do?

This script will allow you to control the lights, thrusters, brakes, and wheels on your trailer from your tractor.
This unifies control of the trailer with the tractor so by pressing the lights key, all lights on your tractor and trailer will toggle. Pressing the crouch button will apply the brakes to the tractor and the trailer. If you want, you can even power your trailer tires to move when your tractor tires roll. Want to apply the parking brake to both the tractor and trailer? Just press "p".

Installation is easy peasy.

Installation Instructions

Step1: Install programmable block with this script on your tractor.
Step2: Install a remote control block on the trailer(s) you want to tow.
Step3: Put the word "brake" into the name of any light(s) you want to act like brake lights.
Step4: Enjoy :)

What's New?

- Massively simplified installation.
- Backward compatible with the old setup.
- Improved performance by streamlining the setup and function.
- When the vehicle cockpit is not occupied, the script will be on "standby" mode and run only when there is a driver.

Thanks for reading :)

Technical Notes (Optional)

Finding the Block that Controls the Rig:
This script functions by monitoring the cockpit or remote control used to pilot the vehicle.
It finds the ship controller by looking for the first cockpit that is occupied, or a remote control block that is under the control of a player that it can find. The script prioritizes cockpits over remote control blocks. Meaning that if you're using a cockpit while someone else is using the remote control block, the cockpit will be chosen as the "signal controller".
Once the script has assigned a "signal controller", this will not change unless your controller is destroyed, or you recompile the script and take control over another ship controller (ship controller = Cockpit or Remote Control).

Finding Thrusters:
It finds the first thruster pointing forward that shares the same grid as the "signal controller".
It does the same for the first thruster pointing backward.
These thrusters get assigned as the reference thrusters in which the thrusters on the trailer will base their thrust.
These will automatically get reassigned if they get destroyed. One draw back, however, is that if you ONLY have thrusters on your trailer, this script will not have anything to base their thrust on and so will not fire.
I will fix this in a future update soon :)

Trailer thrusters will behave properly whether or not you have thrusters on your tractor.

Finding the Lights
The lights are controlled the same way as the thrusters. A "signal light" is assigned by looking for any spot light on the same grid as the "signal controller" and turning every other light on or off depending on the spot light.
Adding the word "brake" into say, the name of red lights at the rear of your trailer and tractor, will cause those lights to become illuminated only when the brake key is pressed (default "c").

Thruster Inversion?
When you hook up to a trailer with your tractor, you can view the thrusters in the terminal and can plainly see that thrusters on the trailer are (for some reason) assigned opposite directions from those on the tractor by the game. This isn't a problem as this script will take this into account and invert the thrusters by default. You can alter this behavior however, by setting the "InvertThrusters" varible to "false". This may be necessary if you're planning to land a ship on your trailer and don't have thrusters attached directly to the trailer but want to use the thrusters on your ship instead (ship thrusters get the proper direction relative to their ship controller).

Powered Trailer Wheels and Applying Braking Force
Installing a remote control block on the trailer(s) allows the programmable block to activate the parking brakes. By monitoring the MoveIndicator from the "signal controller", this will activate when the jump button is pressed or the parking brakes are applied on the tractor.
By default, this script wont power the trailer wheels. You can change that by setting the "PoweredTrailerWheels" varible to "true". There are also two additional settings you can use to tweak the behavior of these wheels, although this is not necessary and the default values work perfectly fine.

- The first variable is the "Available Power" value. This will control the percentage of power available to the trailer tires. This can be useful if you find the trailer keeps swinging out of control. Of course, it is better to adjust the power on the suspension itself from the terminal.

- The second value is the "Powered Interval" variable. This will determine how quickly the power is applied. I find that applying 1% of power per game tick is preferable for stability as opposed to dumping all that power at once.

Final Thoughts
If you've made it this far, you have my thanks :)

This script was inspired by Splitsie's survival series on youtube in which he built the "Goose" semi truck that gave me this idea. Big thanks to him and if you haven't seen this series, I highly recommend it :)

Please feel free to let me know if you have any suggestions or request and I will answer them as soon as possible.
Feedback is very helpful to getting my scripts just right :)
Popular Discussions View All (1)
0
28 Jul, 2021 @ 12:28am
Script Controls Trailer Wheels, Even After Disconnecting Trailer
User5876
29 Comments
Claus 2 Jul @ 7:25am 
cool script thx for this... but the light function switch ALL lights on and off ( also the inner lights inside my Trailer ) is there a function to ignore some lights ? else my trailer is dark inside cause no windows in it... Sorry for my bad english i am from germany...
aveBrian  [author] 15 Oct, 2021 @ 6:32pm 
@Shinobi You know, I never tested it with large grids. I'll have to get back to you on that. Sorry about the oversight.
Shinobi 26 Sep, 2021 @ 5:41am 
So I'm trying to get this to work with a large grid Assault Rover, but no matter what blocks I use for the "Cockpit" it still throws I'm not in one. Is this only for small grids?
User5876 7 Aug, 2021 @ 11:48am 
@aveBrian Awesome, thanks so much, man! I will update right away! Cheers!
aveBrian  [author] 7 Aug, 2021 @ 8:09am 
@fluffybobcat24 There is now a value at the bottom of the scripts description that you can set to "false" that will disable the light management function of the script while preserving all of the other functionality. Let me know if you have trouble and enjoy :)
User5876 30 Jul, 2021 @ 3:55pm 
Is there any way to disable script control of lights on my rover? I would like to turn that functionality off without turning off the whole script.
aveBrian  [author] 6 Jan, 2021 @ 1:39am 
@erichouse02 No, it doesn't. Implementing wheel turning via a script is actually rather challenging. I'll be trying a few things with this script and a few others, so I'll probably be addressing the very feature you're asking about. Sorry, I can't give any kind of estimate on when that'll be though :/
ILickToes 5 Jan, 2021 @ 9:11pm 
Does this mod support trailer wheel turning ?
Asher 28 Jun, 2020 @ 12:59pm 
Hey does this still work?
Asher 15 Apr, 2019 @ 2:24pm 
well tbh @aveBrian I don't think it is your script I think it is a mod conflict as the script works fine on a normal world with no mods, and again this game is still full of random bugs so ya know might be that to. thank you for wanting to get this resolved once I got time myself I will try it with each mod and let you know what I find if anything. Also I should note this was on a server so maybe that is the problem? anyways thanks again :)