Space Engineers

Space Engineers

Not enough ratings
Airlock Controller
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
15.213 KB
21 Jan, 2016 @ 2:18am
3 Feb, 2016 @ 7:57pm
4 Change Notes ( view )

Subscribe to download
Airlock Controller

Description
This script provides automatic control for airlocks by performing the following functions:
  • Automatically recognizes collections of blocks as airlocks, by analyzing block names
  • Depressurizes and Repressurizes the airlock from isolated oxygen tanks, so no oxygen is lost (unless you breathe some)
  • Prevents Interior doors from being open when the airlock is not fully pressurized (unless there's no more oxygen available in the tanks)
  • Prevents Exterior doors from being open when the airlock is not fully depressurized (unless there's no more room in the tanks)
  • Uses lights to indicate the current state of the airlock (Depressurized = Red, Filling/Draining = Blinking Red, Pressurized = White)
  • Pressurizes an airlock from a Programmable Block "Run" command, which can be assigned to a button.
  • Automatically depressurizes the airlock after 3 seconds of being pressurized, to keep the airlock in a depressurized state, when idle, so it's quicker to enter the ship/station than exit (in case you're in a hurry to not suffocate)
  • Provides a global Lockdown command to shut and lock all airlocks.

Script Setup & Configuration

After loading the script into a Programmable Block, configure it by modifying the values of the following readonly variables near the top of the script:

AirlockTag
  • This is the text tag that must be placed in the name of every block you want the script to manage. The default is "Airlock"
DoorTimeout
  • The time, in seconds, that doors will stay open before auto-closing.
LightColor_Pressurized
LightColor_Depressurized
LightColor_Lockdown
  • The light colors that will be used to indicate the current status of each airlock.
LightBlinkInterval
  • The blink rate, in Hz, that will be applied to lights when an airlock is filling or draining.

The rest of the settings deal with reducing script complexity, to avoid the "Script is too complex" exception. You will have to adjust these experimentally, based on your specific setup.

RecollectBlocks
  • Indicates whether the script should collect lists of blocks to managed on every run, or only on the first run. If false, any changes made to managed blocks, or addition of new blocks, will require a "reboot" of the script (by selecting "Edit", "Check Code", and "Remember & Exit") before the changes take effect.
OpsPerRun
  • Indicates how many "operations" will be performed during each run of the script. Reducing this number too far may cause airlocks to become unresponsive or sluggish, unless the update rate of the script is increased.
DebugEnable
  • Enables the printing of debug messages to the Programmable Block's "Detailed Info" section.


Once configured, the Programmable Block must be triggered to run (with no argument) periodically.
The most effective way to do this is with Digi's "Loop Computers" mod, by adding the tag [repeat 0.16] to the name of the Programmable Block. This causes the script to run 6 times per second.

Triggering of the script can also be done by attaching the "Run" action of the block to a Timer Block
which triggers its own "Start" action. DO NOT attach the script to a Timer Block that triggers its own
"Trigger Now" action. This will run the script 60 times per second, which will cause it to malfunction,
as there are certain properties of blocks that do not update that quickly.


Block Setup & Configuration

To configure blocks to be managed by the script, you must first pick a name for each group of blocks that will form an airlock. The name must contain only alphanumeric characters, and all references will be case-sensitive.

Once a name is picked, the following tag (including the brackets) must be added to the name of each block to be managed: [Airlock AirlockName]. The first word "Airlock" can be changed by modifying the AirlockTag variable, described above.

The following block types should be assigned this tag
  • Doors
  • Air Vents
  • Oxygen Tanks
  • Lights

Additionally, for doors on the exterior of the airlock (adjacent to unpressurized space),
the tag must be [Airlock AirlockName Exterior].


Control and Operation
The script implements the following commands (not case-sensitive):

"disable [AirlockName]"
"off [AirlockName]"
  • Disables management of the given airlock, or (if no airlock name is given) the entire script.

"enable [AirlockName]"
"on [AirlockName]"
  • Enables management of the given airlock, or (if no airlock name is given) the entire script.

"pressurize [AirlockName]"
  • Pressurizes the given airlock, or (if no airlock name is given) all airlocks.

"lockdown"
  • Places all airlocks into "Lockdown" mode, where all doors are shut and locked.

"release"
"allclear"
  • Releases all airlocks from "Lockdown" mode, and returns them to previous operational status.


Each of these commands can be executed from the Programmable Block GUI, or by assignment to a button or sensor.
17 Comments
mazrados 1 Jan, 2021 @ 11:50am 
Is it possible to use withought oxygen tanks?
I need something simple, 2 sliding doors next to each other.

All this type scripts I've found don't enable to set names for doors to handle and use all of them.
And I need just particular doors to be handled by script.
MrFox 12 Feb, 2019 @ 7:35am 
=D
DFA.Jaken Veina  [author] 11 Feb, 2019 @ 7:52pm 
In progress.
MrFox 11 Feb, 2019 @ 12:48pm 
Needs update not working
Aether 15 Dec, 2017 @ 8:13pm 
I didn't try it, but I've heard that somes things concerning script or something else has very changed so...
DFA.Jaken Veina  [author] 15 Dec, 2017 @ 7:06pm 
Quite possibly. Almost two years since the last one. Are you having trouble with it?
Aether 9 Dec, 2017 @ 4:53pm 
Does it need to be updated?
DFA.Jaken Veina  [author] 21 Feb, 2017 @ 4:51pm 
The way it's setup, it wouldn't make sense. When an airlock is "pressurized" it only stays that way for a few seconds, then automatically closes all interior doors and depressurizes. Basically, it automatically toggles.
De/Code 21 Feb, 2017 @ 12:44pm 
Is there a "Toggle" command?
KingdomBragg 14 Aug, 2016 @ 1:28am 
Thanks for the response, I should have been more descriptive of the setup. The ship has a small internal space containing a single door, oxy generators, oxy tanks and vents. I've realised what I was hoping for isn't in the controls i.e. disable the auto depressurization keeping the inside pressurized and running the script with a depressurize argument to exit the ship.