Space Engineers

Space Engineers

28 ratings
AAECS - Advanced Automatic Elevator Control Script Guide
By Viruz
Guide on using my script AAECS (Advanced Automatic Elevator Control Script).
   
Award
Favorite
Favorited
Unfavorite
AACES - Summary
This script can be used to create and manage complex but easy to setup elevators without the use of timers or sensors.

Link to script: Script

A single programmable block with this script can manage all the elevators on a grid including support for any grid size. This script is designed in such a way meaning that many of the steps needed in creating an elevator are done automatically (closing of doors, multi-floor management etc).

Individual elevator's settings can be adjusted from within their configuration, you can adjust speed, door timings, elevator smoothness however you wish. You can even setup timers for when certain events happen like arrivals and departures making things such as elevator music and arrival dings possible.

There is also a step by step video tutorial of creating an example elevator.
How to Setup
A video setup example is available here and in the workshop previews: Link.

Text Setup Guide:
Take a look at the "Important details to know" heading before and after reading the steps.

Basic steps:
  1. Firstly, place a programmable block and load the script.
  2. Create an elevator nickname, each elevator has its own unique name which is used to refer to the elevator by commands. This can be anything. You'll need to use this later on.

Basic Construction:
  1. Place a door on the first floor, add the prefix of [L1] to the name of the door. Note: The number in brackets represents what floor the door will be on. You can also place multiple doors per level.
  2. Now continue this by placing door's at each level the elevator should stop at, it's also important that you add the prefix to each door's name, only this time, changing the number with the level of the appropriate floor. E.g. A door at level 4 should have the prefix [L4] at the start of the name. It is important to remember, the prefix needs to be at the start of the door/gate name, otherwise it will not be recognised.
  3. Create your elevator cabin, place your pistons along the shaft axis, the cabin can be any grid size. (Do not worry about the cab being flush with the level as you can adjust this later on).
  4. Once you are happy with your doors and car, you can now finally get it working, select each elevator block, (doors and pistons) and make a group, the group name needs to be formatted as such: [Elevator <Elevator Name>] where <Elevator Name> is the nickname decided by you. An example of a group name is: [Elevator PrimaryCargoElevator]. A nickname is needed as this is how you will refer to the elevator through commands.
  5. Then run the script with the argument "setup" to create the elevator. You will now have a functioning elevator! All you need to do now is setup commands and (optionally) reconfigure the settings of the elevator.

Manually Creating Levels
There is also another method of creating levels, this script was designed primarily to setup elevators all automatically with no manual input for specifying floor heights or messing with sensors/timers (hence the Automatic part of the script name.) The script achieves this by utilising the position of the doors on each level as a reference to that floors position.

However, there is now the option (from 1.3+) to be able to create levels manually with a specified height, in the case that you do not want to have doors on a level (or no doors at all), you can still create levels. This does however require a little more setting up.

One important thing to know, if you want manually specified levels, then it is recommended that you set a reference piston so the script knows the location of the elevator. The level position is determined by an offset from the piston. I recommend setting this to the very bottom piston attached to the main grid. Simply add the prefix "[Reference]" to the name of the piston you want to use as a reference. You do not have to do this, especially if you have only one piston, however it is still recommended.

The configuration for manually created levels is located in the custom data section of the script, a heading/ini section is used to represent a manually craeted level which is in the format of:
[<Elevator Name> L<Level Number>] ; The offset is the number of blocks from the reference piston with the prefix "[Reference]" at the start of the name. Level Block Offset=...

Actual Example:
[PrimaryCargoElevator L2] ; The offset is the number of blocks from the reference piston with the prefix "[Reference]" at the start of the name. Level Block Offset=3

I have made a command to make this process a little easier, it'll create the level for you in the custom data using the template, the command is "lc" and you can find more info in the commands section.

One final thing to note, you are able to use a mix of manually created levels and automatically calculated levels in one elevator with no side effects (that I know of atleast), you are also able to make completely manual elevators with no doors at all if you so wish, although you will still need the group and nickname with the pistons, even if it is just one piston.

Important details to know:
  • An elevator requires a minimum of 2 floors to function, if there are less than 2 floors when you run the setup command, the elevator won't work.
  • If your elevator shaft is wider (based on the placement of the door's) than it is taller, you may have to manually set the axis in the configuration. E.g. If a 2 floor elevator has a 2 block difference in height, and a 3+ difference in width/length, you will have to manually specify the axis. (Y will work in most cases with vertical elevators however you may need to try X or Z in case it doesn't work). Update 1.3: The script now uses the pistons as a reference for the axis, meaning that the axis is determined by the direction of the piston, so this is no longer relevant.
  • Do NOT use the minimum distance piston property to offset your elevator car, it will not work on the other floors, instead use the dedicated offset property in the elevator config. (Have a look at the configuration section).

(Additional) Nickname spaces:
I recommend that you do not include spaces in the elevator nickname, you can still do this, however, you will have to add quotes surrounding the name when setting up commands which can be inconvenient if you forget, this is explained in more detail later on.
Elevator Configuration
By default, each elevator comes with a preloaded configuration, these default settings are optimised for the typical basic piston elevator to work out of the box. However, if you are building a more complex elevator, you may possibly need to modify the settings.

Luckily, this isn't too hard, the configuration settings for each elevator are stored in the custom data box of the programmable block, opening it up will reveal a list of elevators with individual properties, you may be familiar with this type of config from other scripts.

Find the section in the custom data which contains the name of the elevator you want to modify the settings for, it will look something like: [AAECS - Elevator Name]. The list of fields below the section are all the settings for that elevator, simply modify the values which you want to change. The fields and their descriptions are available in the next section Config Options.

Elevator Car Doors
This script also comes with a way of handling doors which are on the elevator cab itself, the elevator cab doors will open when arriving at a floor and close when departing from a floor. Meaning that realistic and mostly safe elevators can be created.

To add these doors to the elevator, place the doors on the cab and add a prefix to the name of the doors, like with the level doors. Only this time, changing the prefix to [Elevator] since the door is located on the cab.

After doing this, add the blocks into the elevator group then run the "setup" command to fetch the blocks when you are done.

Level Exclusion
If you need a door on the cab to not open on a certain level because for example, the floor door
is placed oppositely on that level as opposed to other levels, you can exclude doors from opening on certain floors.

Excluded levels are stored in the custom data for each door. Open up the custom data of the door and you should see [Exclude: ] if you already have a working elevator. If you don't see it, just add it manually.

Now after Exclude: you can type the floor number which you want the door to ignore, type multiple as a list like this: 1, 2, 3, 4, 5.

Example:
[Exclude: 1, 3, 6]
This will mean that the door will only open on floors 2, 4 and 5 and will not open on floors 1, 3 and 6.

An example diagram has been included where each door on the elevator cabin has its custom data shown (in their own highlighted boxes):

Display Signs
This script comes with the ability to make realistic looking display signs you would find in a real elevator such as:

To create one of these signs, place any LCD panel and add the prefix [Elevator] at the start of the name, then add it into the elevator group and run the setup command. You will now have a fully functioning status display sign which can be placed anywhere!

This can also apply to a block which has a single screen such as a control station/flight seat or a sci-fi one button terminal.

Formatted signs:
In 1.6.0, you now have the option of creating your own custom formatted signs rather than the default Arrow Number. To do this, find any signs which you want to set the format for and open the custom data box.

Within this box is how the sign will be displayed. There are two special tags which you need to know about, !A which is the symbol tag, and !N which is the number tag. These are essentially placeholders for the actual value. You can include as many of these tags as you wish.

Example:
This is the default format:
!A !N
This will display as, for example when travelling up:
▲ 1

Second example:
!A -- At: !N -- !A
Displays as:
▲ -- At: 1 -- ▲

By default/when nothing is in the custom data, the sign will use the default template which is set by the Default Sign Format option in the configuration options. This defaults to !A !N which is what can be seen in the real image above and on the script workshop page.

Buttons and text surface providers: (1.2)
You are now able to create these signs within a block which has multiple screens (such as the sci-fi button panel). Add the same prefix mentioned above, except also open up the custom data of the block and add the index of the screen you want to display the elevator sign on.

It is in the same format as from the Level Inclusion section above, where you place the indexes in the brackets. Example:
[Display on: 1, 3, 4]
This will display the elevator status on the first, third and fourth screen in the list of screens.

Important:
Please note, the font has to be monospace as the symbols will not render if it is any other font, there isn't much I can do about this sorry. I may look into using sprites instead at some point in the future but I am not deciding on anything yet.
Config Options
Field
Description
Format
Desired Speed (M/S)
The maximum speed which the elevator will move at while at travelling between floors.
Decimal Number in M/S
Offset (M)
Set this value in metres to offset where the elevator will arrive at each floor. Set the offset to positive for the elevator to stop above the floor and negative for it to stop below it. This is useful when trying to make each floor flush with the elevator.
Decimal Number in Metres
Smooth elevator piston movement on Arrival and Departure (True/False)
Determines whether the elevator will slowdown or speed up when arriving or departing from a floor. Set to False for the elevator to stop as soon as it arrives. Higher speeds with this disabled may cause ou to fall.
Boolean value, True or False
Smoothing Method
Determines how the elevator will slowdown, default is "Linear".
  • Half - The elevator will half its speed when within the smoothing distance. Only recommended for slow moving elevators.
  • Linear - The elevator will gradually slow down/speed up when arriving/departing.
  • Sine - The elevator will rapidly accelerate and decelerate when arriving/departing to/from a floor.
A value from 3 options:
-Half
-Linear
-Sine
Smoothing Distance (M)
The distance from the target floor to the elevator cab where the elevator will begin to slow down. When the elevator is within this range from the target floor, it will begin to slow down according to the "Smoothing Method" chosen.
Decimal number in Metres
Time spent at each floor inbetween calls (S)
The time spent per floor when the elevator has been called elsewhere. When the elevator arrives at floor X but needs to go to floor Y aswell, the elevator will arrive at X, wait this amount of seconds and proceed to Y.
Decimal number in seconds
Name of timer block to trigger when arriving
The name of a timer block which then be triggered whenever the elevator has arrived at a floor.
Name of timer block
Name of timer block to trigger when departing
The name of a timer block which then be triggered whenever the elevator has departed from a floor.
Name of timer block
Elevator Axis
The axis of the elevator shaft, the script needs to know the axis of the shaft to know the current state of the elevator. The script will automatically calculate this based on the position of all the elevator blocks when this value is set to "Auto", however, you can also change this manually by entering an axis from X, Y and Z.
From values:
-X
-Y
-Z
-Auto
Door Enable/Disable delay (S)
Will be applied as soon as any door opens or closes, when a door opens or closes, there will be a small period of time where the doors will still be on. Default value is 0 seconds.
Decimal number in seconds.
Assume arrival on limited bounds (True/False)
When true, the script will ignore if the elevator has arrived on the elevator endpoints if every piston is fully extended/retracted.

For example, when the target floor is the first floor, but the pistons are all the way retracted, the elevator will get stuck, setting this to true will cause the script to consider the elevator as arrived at the first floor anyway, even if the elevator is not considered to be fully at the first floor. This is useful for eliminating the small extra height that comes with a piston head.
Boolean value, True or False
Invert arrow on signs (True/False)
When true, any signs will have the direction arrow inverted.
Boolean value, True or False
Distance Epsilon Tolerance (M)
The distance from the target floor to the elevator cab where the elevator will stop. The elevator does not stop directly at the position of the level due to instability. Instead it stops within a certain distance from the floor. Adjust this if the floor does not line up perfectly, however, low values below 0.02 may cause instability.
Decimal number in Metres
Default Sign Format
The default format for which elevator signs/LCD's will be formatted as. If a custom format is entered for each sign, the default is overridden. See the "Formatting Signs" section under the configuration section.
Formatted string consisting of !A and !N special tags.
Enforce doors open/close (True/False)
Controls if the script will continually open/close doors. When true, the doors can only be controlled by the script, when false, the doors can be operated manually in addition.
Boolean value, True or False
Commands
In order to actually use the elevator, you will need to setup commands. Commands are taken in as arguments. Run the script with the command as the argument to execute the command.

General Commands
Command
Description
setup
Fetches all elevators on the grid or on sub-grids.
update_settings
Updates each elevator's configuration according to changes made to their configuration section in the custom data.
lc
Creates a new manually created level template for an unnamed elevator.

Running produces this in the custom data:
[ExampleElevatorName L0] ; The offset is the number of blocks from the reference piston with the prefix "[Reference]" at the start of the name. Level Block Offset=0
lc <Elevator Name>
Creates a new manually created level template for the elevator provided.

Example:
lc PrimaryCargoElevator

Running the example produces this in the custom data:
[PrimaryCargoElevator L0] ; The offset is the number of blocks from the reference piston with the prefix "[Reference]" at the start of the name. Level Block Offset=0
lc <Elevator Name> <Level Number>
Creates a new manually created level template for the elevator provided with the level number of 3.

Example:
lc PrimaryCargoElevator 3

Running the example produces this in the custom data:
[PrimaryCargoElevator L3] ; The offset is the number of blocks from the reference piston with the prefix "[Reference]" at the start of the name. Level Block Offset=0
lc <Elevator Name> <Level Number> <Offset>
Creates a new manually created level template for the elevator provided with the level number of 3. This fills out the "Level Block Offset" property with the new value provided.

Example:
lc PrimaryCargoElevator 3 5

Running the example produces this in the custom data:
[PrimaryCargoElevator L3] ; The offset is the number of blocks from the reference piston with the prefix "[Reference]" at the start of the name. Level Block Offset=5
Elevator Action Commands:
Command
Description
goto <Elevator Name> <Action>
Moves the elevator according to the set action, actions can be floor numbers (e.g. goto TestElevator 3) or keywords: top, bottom, up or down. These options can be seen below:
  • up - Moves the elevator one floor above.
  • down - Moves the elevator one floor below.
  • top - Moves the elevator to the top floor.
  • bottom - Moves the elevator to the bottom floor (Floor 1).
  • Any Number - Moves the elevator to the specified number, IMPORTANT: Elevators start at 1.
Examples:
The elevator name for these examples is "PrimaryCargoElevator"
goto PrimaryCargoElevator 4
This will move the elevator to the fourth floor.

goto PrimaryCargoElevator bottom
This will move the elevator to the first floor.

goto PrimaryCargoElevator up
This will move the elevator one floor up.

IMPORTANT:
If the name of your elevator contains spaces (such as: Primary Cargo Elevator), you will need to surround the name of the elevator in quotes. E.g.

This will NOT work:
goto Primary Cargo Elevator 1
However this will:
goto "Primary Cargo Elevator" 1
This goes for all commands where you need to reference an elevator name.
reset <Elevator Name> -groundfloor
Resets the elevator queue, if you want to make the elevator also move to the ground floor, add the switch '-groundfloor'

Examples:
reset TestElevator -groundfloor
This will remove every call in the queue and set the target floor to the first floor.

reset TestElevator
This will remove every call in the queue but will keep the elevator at the current floor it is already at.
Troubleshooting
If you are having issues with your elevator, then have a look at the list below. This section will try to address some of the more common issues regarding elevator setup or configuration. I will add more to this section as issues are reported.

Ingame Errors:
No pistons found:
The script could not detect any pistons in your elevator, make sure that you have the pistons included in the elevator group.

Less than 2 floors found:
Elevators need a minimum of 2 floors to function, when this error happens, the script could not detect at least 2 floors, either manually created or created through doors. Make sure that you have included at least 2 floors by checking all your doors are apart of the same group and also you have the floors in the correct order (1, 2, 3 etc).

Ingame Warnings:
The name contains spaces:
Nicknames which contain spaces can be awkward to deal with when using commands. If you include spaces in your elevator nickname, make sure you surround the name in quotes when refering to the elevator by commands. E.g.

Use this:
goto "Primary Passenger Elevator" 1
Instead of this:
goto Primary Passenger Elevator 1

No reference piston found:
Elevators need to have at least one reference block so the script knows where the elevator is and what axis the elevator is on. The script uses a piston to determine this, this is known as the reference piston.

If you have not set the reference piston, the script will instead guess what piston you are using. If you are using manually created floors, it is especially important that you set a reference piston as the elevator may behave unpredictably and not go to the correct height of each floor.

The reference piston set should be the very base bottom piston of the elevator if you are using multiple pistons. Set a reference piston by adding the prefix [Reference] to the start of the name of the bottom elevator piston and running the setup command.

Other issues
The bottom right terminal output is buggy with large portions of the text being yellow
This is a bug which is out of my control, Keen implemented a new feature in Automatons which seems to be somewhat broken. It would allow custom colour output however there are a few issues with it.

I have created a bug report[support.keenswh.com] on the forums and hopefully it will get fixed soon. In the meantime, parts of the text will be broken until it gets resolved. :/

Elevators Getting Stuck
This is a common problem and can come down to three main problems, one is that the script has detected that the elevator is on an incorrect axis, or that the pistons cannot reach the top and bottom of the elevator causing the elevator to indefinitely stay stuck while the piston tries to extend beyond the max distance or the pistons are simply getting stuck.

Solution 1: Clang
If you build an enclosed shaft flush with the wall, it is likely that the pistons will get stuck/collide, to fix this, turn up both force sliders of the pistons to maximum and also turn on share inertia tensor (Only recommended if the elevator is on a station, ships shouldn't use this.).

Solution 2: Axis detection
One common issue is that the script thinks the elevator is on a different axis then the actual axis it is on. The script uses the position and orientation of the pistons as a reference to the elevator axis, whichever way the pistons face, the axis will change.

The script will choose the first piston it sees in the piston group as a reference. The important thing is is that the reference piston needs to be on the same main grid as the rest of the elevator (shaft, doors, etc), so not on any sub grids.

On single piston elevators this is fine, however on multiple piston elevators it can cause issues as the axes can differ between sub grids.

To fix this, manually specify the reference piston, add the prefix tag [Reference] to the main first piston which is attached to the main grid.

Solution 3: Piston Limit Bounds
This scenario can only occur if you have the pistons extending to their maximum or minimum extensions (10m for large, 2.5m for small).

The script does not count the expected arrival time of the elevator, this is because it would be far to complex and inaccurate, instead the script will wait and detect the elevator arriving/departing then do things such as unlock doors etc. However, if your pistons are fully extended/retracted, the script will be indefinitely waiting for the elevator to arrive where they cannot travel to.

This can be fixed from the elevator configuration, change the Assume arrival on limited bounds (True/False) property to True so that even if the script has not detected the elevator, but it is fully extended/retracted, the script will count the elevator as arrived anyway.

The elevator car is not flush with the floors
This is a simple issue which only requires changing the offset property of the elevator config. Simply open the elevator config and change the offset value to whatever you need it to be. The offset will be added onto the elevator's position when considering floor heights.

Do NOT use the minimum and maximum extension properties of the pistons, leave those to the min/max values.
14 Comments
StikShift4Life 11 Jun @ 10:47pm 
@The_Bat_Daddy, in SE in general, mechanical traversal measurements don't come out the way you think they should when near its limits. One thing you can try, is raise up your bottom floor one block (and all others above it), and see if the issue persists. One easy way to do this, is drop the bottom of the piston down one block. In other words, avoid your bottom floor being located close to the min length of the piston.

I have had numerous issues with many other things because of this, and adding extra clearance seems to fix most of it.
The_Bat_Daddy 25 Jan @ 6:23pm 
I've run into an interesting "issue". The elevator will be flush on the first floor after adjusting the offset, but then way off on all the above floors. If I make it flush with one of the upper floors, it is no longer flush with the first.
Gizombo 15 Sep, 2023 @ 4:51am 
@Viruz Awesome, thank you
Viruz  [author] 15 Sep, 2023 @ 2:41am 
@Gizombo, Atm, there isn't a way to do this, but I could possibly add an optional alias tied to each floor which can then be referenced by !ALIAS. I'll probably add that in the next update either this week or next week.
Gizombo 14 Sep, 2023 @ 6:42am 
Is there a way to give floors a custom name for displays? i.e. !A -- !N <floor name> -- !A which could display as: " ^ -- 3 Engineering -- ^ "
E.V.A Blouseblanche 15 Jul, 2023 @ 12:42pm 
Hello, not sure if I'm taht innatentive or if it's not written in, or if I fucked up somwhere else, but I can't seem to make an elevator work by having it's bottom level start at 2. is it normal ? it's rather inconvenient to have a single level aboard my ship be called n°1 by an elevator and N°2 by another
Unreal 13 Jun, 2023 @ 11:09am 
When i spawn my ship the elevator spawns below the floor and wont operate until i do a recomppile?
Viruz  [author] 6 Dec, 2022 @ 1:56pm 
Well, this is an elevator script, but if your ramp uses pistons along one axis with a start and end point, I don't see why not... Though you're probably better off just doing it in vanilla or using another script.
Kimowal 6 Dec, 2022 @ 9:22am 
could it be used to make a ramp for ur ship also?
Viruz  [author] 21 Nov, 2022 @ 11:44am 
@JWA, Update is released! lmk if there's any issues with it.