Space Engineers

Space Engineers

1,059 ratings
Whip's Auto Door and Airlock Script
5
3
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
0.602 MB
Mar 30, 2015 @ 5:34pm
Sep 12, 2021 @ 12:01pm
50 Change Notes ( view )

Subscribe to download
Whip's Auto Door and Airlock Script

In 1 collection by Whiplash141
Whip's Scripts
22 items
Description

  Description
"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 fully open for over 3 seconds (10 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 3 seconds, then close. This script also supports an INFINITE amount of simple airlock systems.


  Instructions
  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.


Airlocks
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 :)

Naming:
  • 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"
Rules:
  • 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)=3 Default hangar door auto close time (s)=10 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)=3

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 mod.io)
Popular Discussions View All (8)
99
May 7 @ 7:30am
PINNED: Bug Reports
Whiplash141
22
Mar 3 @ 9:35am
Feature Requests
CTH2004
1
Jul 23, 2021 @ 5:36pm
[TESTED] Air Vent Variation of Whiplashs Airlock System with Loss Protection
Pax'Jarome
< >
477 Comments
Rick Sanchez Apr 8 @ 6:06am 
This is exactly what I wanted!
jglenn1562 Apr 7 @ 12:25pm 
Is there an alternative script or a way to change it so that I got to add a tag to include doors, and not exclude?
Dekiru Mar 6 @ 11:23am 
On my previous comment, I renamed my "Offset Door" to "Sliding Door" and recompiled the script then it detected the doors.
Dekiru Mar 6 @ 11:19am 
Hi there Whiplash, long time fan of your scripts. Unfortunately it seems like the script does not work with DLC doors. All my doors has the custom data automatically added, but the airlock part does not detect the offset doors. How could I go about fixing it?
Whiplash141  [author] Mar 6 @ 10:41am 
No it doesn't and no I'm not adding air vent support. Simply set your airlock to always depressurize.

I really couldn't care less what other scripts do, so that is not compelling. This script works precisely how I want it to; quick and simple. No convoluted setup or implicit time delays.
Typhon Plume Mar 6 @ 4:29am 
Just to add on, that reason and others is why every other airlock script and system involves controlling the air vent for a better airlock.
Typhon Plume Mar 6 @ 3:17am 
Well no vent control for depressuring the lock, means loss of oxygen and if someone does it right, there going to be yeeted from the ship into space. Might want to rethink the air vent part.
Whiplash141  [author] Mar 5 @ 5:10pm 
It stops you from spacing your ship. It is a _simple_ airlock system as mentioned above.
Woodzy Mar 4 @ 1:37pm 
This doesnt use air vents. how is this an airlock again :o?
Whiplash141  [author] Mar 3 @ 9:33am 
bad mod lol