Space Engineers

Space Engineers

34 ratings
Vehicle control overriding script
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
564.635 KB
16 Nov, 2019 @ 7:42am
5 Oct, 2021 @ 3:57am
19 Change Notes ( view )

Subscribe to download
Vehicle control overriding script

Description
        Description
    This script overrides the way you control your ground vehicle. Instead from the default way of ground vehicle control when you can control only its acceleration, this script will maintain speed that vehicle accumulate when relative direction key was pressed. It wouldn't work on vehicles that have suspensions placed on rotors! It's some sort of cruise control script that includes:
  • Speed control - now your vehicle won't accelerate on down hill roads on its own. Also you can adjust maximum speed for forward and backward movement, and acceleration (relative, it will be used by script to accumulate required speed). While moving forward holding "S" key vehicle won't start movement backwards after full stop and vice versa;
  • Handbrake control - no more loosing stuff by pressing "P". Script will automatically switch handbrakes. If you need to do it in emergency event you can do it by "move up" action, space bar key by default.
  • Control over reverse and braking lights;
  • Automatically adjust wheels suspension strength relative to vehicle mass and local gravity. It will check truck mass whenever you get control over it or you can put programmable block on toolbar or timer with argument "mass", it necessary for applying proper suspension strength values;
  • Attaching Trailers. But only one at same time or throught dolly. And control same systems: suspensions, lights and handbrale. Will apply proper override on trailer suspensions, to provide additional impulse and prevent jackknifing.

        Deployment preparation
    Vehicle must meet next requirements:
  • Wheel suspensions names must contain labels relative to side they are placed on. Like: "wheel suspension right"; *
  • Brake lights name must contain "brake"; *
  • Reverse lights name must contain, guess what? Yes - "reverse" label; *
  • Put on controller toolbar programmable block with "trailer" argument;
  • Put timer on vehicle and set it delay to one second. Put timer on vehicle and set it delay to one second. Set in timer actions to run programmable block that contains this script with argument "strength". Put "start" action in there too. And start countdown;
  • Put timer on vehicle and set it delay to about thirty or more seconds. Put timer on vehicle and set it delay to one second. Set in timer actions to run Programmable block that contains this script with argument "mass". Put "start" action in there too. And start countdown; (not necessary)
  • If vehicle intended for pulling trailers, put there rotor that must be placed facing up and with zero angle mark relative to forward movement. Put top rotor part on trailer hitch facing forward.
* This also apply to trailers.


        Settings
    First time you run this script on a vehicle, it will write pattern data in it's programmable block custom data.

Controller name: Seat Driver Steering wheel name: null Keyboard steering: False Coupler name: Coupler Is semi: True Acceleration: 0.2 Forward speed: 130 Backward speed: 20 Trailer controller name: Trailer Control Truck unit mass: 85618.73

Cockpit name: name of controller, by default it's "Cockpit". It can be cockpit or remote control block.
Steering wheel name: rotor that used as steering wheel. Purely decorative
Keyboard steering: if true it script will hold wheels turn angle.
Coupler name: name of rotor that will be used as coupler for [semi] trailers.
Names must exactly match the name of the blocks. Case sensitive
Is semi: describes type of truck to trailer connection. If your vehicle is semi-trailer truck that change this value to true. It necessary in applying proper suspension strength values.
Acceleration: relative to programmable block update frequency value.
Forward speed: as the name suggests.
Backward speed: as the name suggests.
Trailer controller name: name of trailer controller that will be used in switching brake on trailer.

    Commands:
  • trailer - used to couple truck with trailer;
  • mass - will recalculate suspensions strength;
  • strength - applies suspensions strength. It won't do this instantly. To prevent vehicle going a fly, will increase it slowly;
  • full - full throttle.

        Tips
    You can convert any truck to be able to attach trailers to it, by building rotor as show in screenshots. Adjust it's height to maximum and remove rotor head. On the trailer, the upper part of the rotor must be placed exactly at the same height as if it were connected to the rotor. There is no difference between advanced or simple rotor, just make some space around it, and don't forget to set maximum height.
    If you use vanilla 1x1 suspension or Vanilla Style 2x2 4x4 Wheels on your vehicle, mixed with other sizes, will be applyed wrong suspension strenght to 1x1 and 2x2 wheels. You must consider which size to use, 1x1 2x2 or bigger. If you have something like this, then you must change _truckSuspensionSoftnessFactor value in script to one of those: 5.5f, 6f, 6.5f. The lower value, the harder suspension.

        Conclusion
    Surely there are scripts on workshop that do same thing. But i did this one to satisfy my own needs. Examples of how to set it on trucks and trucks that uses it you can find on my workshop page.

        Log
[22:05:21]: Fixed issue when script could't find coupler block. That pevents it from working on vehicles without it.
Also check delegate for coupler block was changed from SameGrid to SameConstruction. Wrong line was parsed to truck mass variable. Thanks to Silat Endes for notifing me about that problem.

[~:01:21] : "Because is starts to move as a tram" now will not. Now override tooks current pich angle of your vehicle to make start a lot smother. If you have feeling that vehicle became weaker just add "full" command to your toolbar. And you will have same tram start as before. Steering wheel support. If you want to see that turning thing in your cab you can assing a rotor to be your personal steering wheel. You can also use different control over steering by changing "Keyboard steering:" from false to true in custom data.

[27:11:20] : Now hooked up with VDS script. So now when you will attach trailers, VDS will gather all turn signals on it, and also recalculate cargo volume.
9 Comments
Silat Endes 23 Apr, 2022 @ 8:29pm 
Hi I'm looking where to change steering wheels angle from 40 on 0 speed to something less. Because collision on very slow speeds make build skip or stop.
Silat Endes 24 Apr, 2021 @ 12:34pm 
hi i got problem with this script missing some blocks i send you invit so i can sent you link to my world
Prellentor  [author] 25 Feb, 2021 @ 8:05am 
Didn't thought that somebody actually using it. Well now steering must be as before. But for acceleration and lets say engine power you should shoot "full" command as argument. You as always can put it on to a tool bar.
Prellentor  [author] 25 Feb, 2021 @ 7:28am 
Well. That was a new feature. I just had no time to put switch for that. It's steering wheel support. Now it should hold wheels angle. And it can cause clang because of settings.
DecaRabia 21 Feb, 2021 @ 1:40pm 
Hi! Something went wrong with the latest version. I have updated the script and it is no longer usable, the wheels do what they want.
I really like this script, hope you can fix it.
Niel 21 Feb, 2021 @ 12:50am 
Sorry but looks like something is broken. The script runs but must be an issue somewhere with steering control and steering wheels.
ronidude 1 Jul, 2020 @ 12:14pm 
amazing
Prellentor  [author] 15 May, 2020 @ 1:43am 
@British89 Mostly because of DAS script. But i didn't like how it worked. So i did my own.
British89 14 May, 2020 @ 5:52pm 
How has no one rated or commented on this, It's brilliant good job pal