Space Engineers

Space Engineers

848 ratings
Whip's Auto Door and Airlock Script
File Size
0.595 MB
Mar 30, 2015 @ 5:34pm
Mar 18 @ 11:53am
47 Change Notes ( view )

Subscribe to download
Whip's Auto Door and Airlock Script

In 1 collection by Whiplash141
Whip's Scripts
18 items

"Sure, I could turn around and close the door like a civilized man.
Or I could let a robot do it for me... like a modern man.
    - Acarii on the virtues of automatic doors

This script will close any door once it has been open for over 4 seconds (15 seconds for hangar doors). The duration that a door is allowed to be open is independent of the status of any other doors. This is to say that if I open one door at a certain time then open another door a second later, each door will stay open for 4 seconds, then close. This script also supports an INFINITE amount of simple airlock systems.

  1. Place this script in a programmable block
  2. (Optional) Set up airlock systems
If you don't want/need the airlock functionality, only step (1) is necessary!

Auto Door Closer
The script will fetch ALL doors on the grid and automagically close any
door that has been open for a set number of seconds. Doors can also be excluded from
this feature.

Changing the Auto-Close Interval
You can change the auto close interval one of two ways:
  • Globally by changing the "auto close time" in the Custom Data of the Programmable Block
  • Per door by changing "Custom auto close time (s)" and setting "Use default auto close time" to false in the Custom Data of a Door.

Excluding Doors:
Add the tag "Excluded" anywhere in the door's name to exclude it from auto closing. Hangar doors are excluded from auto closing by default, but you can change that in the Custom Data of this programmable block.

This script supports the optional feature of airlock systems. Airlock systems are composed of AT LEAST one Interior Door AND one Exterior Door. The airlock status lights and sound blocks do not affect the functionality of the doors so if you don't have space for them, don't fret :)

  • Interior doors should be named like so: "[Prefix] Airlock Interior"
  • Exterior doors should be named like so: "[Prefix] Airlock Exterior"
  • (Optional) Airlock status lights should be named like so: "[Prefix] Airlock Light"
  • (Optional) Airlock Sound Block should be named like so: "[Prefix] Airlock Sound"
  • The "[Prefix]" is the unique name that you group your airlock doors by

    Example Names:
    • "Main Airlock Interior" and "Main Airlock Exterior"
    • "[Main] Airlock Interior" and "[Main] Airlock Exterior"
    • "Potato Airlock Interior" and "Potato Airlock Exterior"
    • "1337 Airlock Interior" and "1337 Airlock Exterior"
  • An airlock system is composed of at least one Interior Door and one Exterior Door. You can have more than one of each type of door. If you do not have one or more Interior and Exterior doors in your airlock system, that particular system will be ignored.
  • Prefixes are case insensitive and spaces are ignored
  • Doors with the same prefix are linked together in an airlock system
  • You do not need an airlock light for the doors to function properly
  • For each airlock system, if an Interior Door is opened, all Exterior Doors are locked and vice versa
  • Each airlock system operates independently of others

  Custom Data Configuration
I've rewritten this code (yet again) to support Custom Data configuration. This means that you do not need to touch any values inside of the code.

Programmable Block Config
In the Custom Data of the programmable block, you can change the global default auto close intervals as well as any and all of the name tags used by this script.
[Auto Door and Airlock - General Config] Enable automatic door closing=true Enable airlock system=true Ignore all hangar doors=true Default regular door auto close time (s)=4 Default hangar door auto close time (s)=15 Auto door exclusion name tag=Excluded Interior airlock door name tag=Airlock Interior Exterior airlock door name tag=Airlock Exterior Airlock light name tag=Airlock Light Airlock sound block name tag=Airlock Sound

Per Door Config
By popular request, if you want to set auto close intervals per door, you can do so in the Custom Data of a door.
[Auto Door and Airlock - Door Config] Use default auto close time=true ; To use a custom auto close time, set "Use default auto close time" to false Custom auto close time (s)=4

Airlock Light Config
Because hardcoding stuff is mega lame, I've also added configuration settings in the Custom Data of light blocks that are being used as airlock indicator lights.
[Auto Door and Airlock - Light Config] Turn on when airlock is open=true Airlock open - Color (R,G,B)=255, 40, 40 Airlock open - Blink interval (seconds)=0.8 Airlock open - Blink length (%)=50 Turn on when airlock is closed=true Airlock closed - Color (R,G,B)=80, 160, 255 Airlock closed - Blink interval (seconds)=0.8 Airlock closed - Blink length (%)=100

  Author's Notes
This script has been rewritten (on 2021/02/22) to support Custom Data configuration. The script is still very performance friendly, and this should make configuring stuff much cleaner since you no longer need to edit variables in the code.

This is/was my first script, I hope y'all enjoy! :)

Thanks to LordTylus for the script in his Self-Maintaining Survival Ship (no longer available :( ) that I based the logic of the auto door closing on. (Very spiffy design :) )

If you have any questions, comments, or concerns, feel free to leave a comment.

- Whiplash141 :)

(Do not reupload without permission, not even to
Popular Discussions View All (5)
Aug 17, 2019 @ 12:42pm
PINNED: Bug Reports
Aug 24, 2020 @ 2:19pm
Feature Requests
Apr 15, 2018 @ 1:57pm
How can I setup an Airvent to work with this?
< >
DR4G4L May 6 @ 3:39pm 
Thx, I started placing double doors 2 blocks apart, you just saved me from setting up like 100 sensors. Great job.
Whiplash141  [author] May 6 @ 3:34pm 
That or you can close the external door(s) manually, but yes.
DR4G4L May 6 @ 3:27pm 
So when named for airlock, open "external", enter, wait 4 sec for it to close, then "internal" should be available?
Cpt.Sovereign-Hun May 5 @ 11:05am 
Hi whiplsh can you upload some help picture for those people who's up something during the setup.....i hope that's enough information...
Whiplash141  [author] Mar 18 @ 11:55am 
@Aurai: That issue should be fixed as of 42.0.2 :)
Whiplash141  [author] Mar 6 @ 5:58pm 
I'll look into that, that was one of the lesser tested parts of this rearchitecture.
Aurai Mar 6 @ 1:47pm 
Hey Whip, having issues changing light colours for this one, I change it in the custom data, and then hit ok. When i go straight back into the custom data the values in RGB have returned to default. I can change blink interval ect ok. but for some reason colour keeps resetting? Any advice?
RogueCmdr Feb 22 @ 7:35pm 
@whip works now - Thank soo much. I dont like any of the alternative scripts for doors out there. your scripts are always the best mate*
Whiplash141  [author] Feb 22 @ 4:10pm 
This script has undergone a rewrite, but the functionality is backwards compatible. Now all configuration is done via Custom Data so that you do not need to edit code to change default values.

Additionally, you can specify auto close delays per-door if you so desire.
Whiplash141  [author] Feb 20 @ 10:03pm 
@RogueCmdr @Dondelium:

I looked into the issue y'all were having. It appears that the script was downloading as a zip file within a zip file . That is definitely not normal as it should only be a single zip file. I forced an update and now it appears to be working. Lmk if this fixed the issue for y'all.