Space Engineers

Space Engineers

1,327 ratings
Whip's Auto Door and Airlock Script
3
2
5
3
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
630.981 KB
30 Mar, 2015 @ 5:34pm
12 Sep, 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 that I initially based the logic of the auto door closing on. It was.one of my first exposures to C# and partially responsible for piquing my interest in programming :)

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)
111
14 Apr @ 10:37am
PINNED: Bug Reports
Whiplash141
24
10 Jun @ 10:35pm
Feature Requests
CTH2004
7
14 May, 2021 @ 9:40pm
How can I setup an Airvent to work with this?
rottielover
542 Comments
Whiplash141  [author] 31 May @ 4:31pm 
This script does not control airvents at all. It simply prevents you from spacing all of your oxygen out of a simple airlock. If you want to preserve air, simply set the airvent in your airlock to always depressurize.
DoPa 31 May @ 1:33pm 
Hi, it works quite well but one thing is missing. Before the airlock opens, the pressure in the airlock should decrease and when I'm in the airlock I should blow it in again so that oxygen isn't constantly lost.
Darth Porgus 3 Feb @ 3:36pm 
Thanks for the response!
Deapri 2 Feb @ 11:29pm 
@Darth Porgus Isy's script interprets the positioning of the doors and inherits behavior based on that with control in exclusions. I feel this script offers more overall control of the setup and effective application. More setup is required however it is my opinion this script better suits my uses.
Whiplash141  [author] 2 Feb @ 10:43pm 
This is 4 years older. Aside for that I have zero clue because I only use scripts I write.
Darth Porgus 2 Feb @ 3:10pm 
How does this differ from isy's simple door script?
Deapri 19 Jan @ 3:37pm 
Which I could edit a post, anyway, the setting is Ignore all hangar doors=true set it to false
Deapri 19 Jan @ 3:36pm 
Hangar doors are excluded by default change the custom data on the programming block to enable them.
xtravince 13 Jan @ 2:10pm 
hi, this script is great thank you very much :steamthumbsup: , but when I install a hangar door it doesn't work with it, it doesn't close and there is no custom data (I waited for the refresh time)
Bacon 30 Sep, 2023 @ 9:45pm 
Thank you very much :)