Space Engineers

Space Engineers

178 ratings
AutoLevel
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
252.275 KB
Apr 20, 2018 @ 12:59pm
May 14, 2020 @ 6:37am
14 Change Notes ( view )

Subscribe to download
AutoLevel

Description
AutoLevel Script - Automatically aligns your ship level to the pull of gravity with various control options for customisation

Use instructions:
Basic Use
This is how to set up the script with no extra features, if you want to use the additional features (e.g. disabling so you can turn and automatically stopping when the ship is level) please read the "advanced use" section below

1. Ensure that your ship has a remote control and at least one gyroscope
2. Install the script to a programmable block
3. (Optional) Set up a button to Run the programmable block in the cockpit hotbar, ensuring that when it asks for an argument you type something (doesn't matter what)
4.Run the script via the interface menu with any argument other than an empty one (e.g. "r", "start", "go" but don't leave the box empty) or the button set up in step 3
5. The ship should automatically level itself, to stop the script press the button or run the programmable block again

Advanced Use
1. Ensure that the ship has a remote control (if there are multiple, you can use the REMOTE_CONTROL_NAME variable to select a specific controller) and at least one gyroscope
1.1 Ensure that the remote control is correctly orientated (the round light should be facing "forwards" relative to your ship)
2. Change the script by clicking the "Edit" button in the programmable block. You are looking for the variables just below the usage instructions in the script, do not change anything below the do not edit warning unless you know what you're doing. The variables are as follows:
2.1 - REMOTE_CONTROL_NAME is used to choose a remote control if there are more than one on your ship, type the name inside the "" (e.g. string REMOTE_CONTROL_NAME = "Remote Control 1";)
2.2 - CTRL_COEFF is used to define the turn speed, if your ship is overshooting, reduce this, if it is turning too slowly increase it by a small amount (e.g. 0.1) and then try again. Large changes may mean your ship is uncontrollable and will be damaged, you have been warned!
2.3 - stopWhenLevel is used to decide whether the script should stop running once the ship is level (true) or continue to run (false)
2.4 - If you want the ship to still be controllable (i.e. to allow you to turn - you can set cockpitFeaturesEnabled to true
3. Run the script with any argument other than an empty one (e.g. "r", "start", "go" but don't leave the box empty)
4. If stopWhenLevel is false, you can stop the script by running it again with the same non-empty argument as described in (3)

Note - Please let me know in the comments on the script if you run into any issues and I'll get them fixed as soon as I can

Common Issues and Fixes!!
If your issue is in the list below please try the fix before posting a comment, if your issue is not below or the fix doesn't solve it feel free to drop a comment and I will either let you know how to fix it or fix the bug that is causing it!

Issue: My ship pitches to an angle other than level with gravity
Probable Fix: Ensure that your remote control block is oriented correctly (facing the front of the ship and the correct way up) and recompile the script to ensure that it has up to date values for the ship.

Issue: The script does not appear to do anything when I run it
Probable Fix: READ THE INSTRUCTIONS - a few people have had issues that would have been fixed by just making sure all the instructions were followed. Make sure you have all the blocks required. Ensure that the argument box is not empty. Also check the custom data of the programmable block for error messages as these may give you a clue as to why the script is not working.

Issue: My ship turns too fast / too slowly
Fix: Modify the "CTRL_COEFF" value at the top of the code. I recommend small changes, so if it's at the default 0.3 and is turning too slowly, try 0.4 and then see what it's like. Large changes may mean your ship goes out of control and I won't be held liable for destroying your precious creations! YOU HAVE BEEN WARNED!
Popular Discussions View All (1)
0
Sep 23, 2021 @ 7:43am
Script refactor
Gate
149 Comments
Deizelpunk Feb 2 @ 12:26pm 
Is there a way to have this script ignore yaw? It works fine to keep it level, but now i cant steer my ship yaw wise... I reserved a gyro for yaw but its fighting against the script
OK Dec 15, 2024 @ 7:27am 
any way to prevent this from locking the rotors of sub-grids?
NerVeN Oct 26, 2024 @ 4:03am 
On "Check Code" it crashes the game :( Any suggestions?
liquid_confidence Oct 23, 2024 @ 7:59pm 
@Adrios is your Remote Control correctly oriented? If you roll to one side the Remote Control is probably facing upwards, meaning it was installed sideways.
Adrios Oct 19, 2024 @ 9:22pm 
How do I adjust the angle, my ship got turned on its side?
Rocketman Aug 24, 2024 @ 10:25am 
how do i make it auto level but with rotors?
LePapot May 10, 2024 @ 6:05am 
Works like a charm! Thank you, been looking for a mod like this for a while
Into May 21, 2023 @ 7:04pm 
How do I set up an angle? I need a pitch up of 16°
HackLab Mar 12, 2023 @ 1:12pm 
Hello @Dixi Normus, @Archon!
I'm developing a flight system script that goes beyond auto leveling. I'm using your code for the alignment relative to the gravitation vector. May I have permission to publish my script, which includes your code?
Of course you will be credited as a co-author.
- HackLab
spEeͥD`eͣxͫ Jan 29, 2023 @ 3:50am 
Weird, does level it. But overshoots and just keeps on going into that direction