Airlock Status Lights 0/5 (3)

posted in: Scripts | 0

This script can be used to control interior lights to indicate when an airlock is pressurized/depressurized.

To set up, have an Air Vent and Interior Light(s). If your Air Vent is named “Air Vent 1″, name the Interior Light(s): “Air Vent 1 Light”. You can have multiple lights for a single vent, just name them all the same (in our example, “Air Vent 1 Light”).

Once that is done, paste the script below into a programmable block and set a timer to run the programmable block however frequently you want.

When the air vent is depressurized, the light(s) will be red, when it is pressurized, it will be green.

You can have however many lights associated with each Air Vent as you want. The lights are always on, so if you want to make them blink, set the blinking parameters as you prefer. The script will only change the color of the light between red and green according to the pressurization status of the airlock.

void Main() {

    List<IMyTerminalBlock> vents = new List<IMyTerminalBlock>();

    // Load "vents" list with of Air Vents

    for (int i = 0; i < vents.Count; i++)
        IMyAirVent vent = vents[i] as IMyAirVent;
        List<IMyTerminalBlock> lights = new List<IMyTerminalBlock>();
        GridTerminalSystem.SearchBlocksOfName(vent.CustomName + " Light", lights);
        Boolean pressurized = vent.DetailedInfo.Contains("Room pressure: 100.00%");
        Color red = new Color(255, 0, 0);
        Color green = new Color(0, 255, 0);
        for (int j = 0; j < lights.Count; j++)
            var l = (IMyInteriorLight)lights[j];
            if (pressurized) {
                l.SetValue("Color", green);
            } else {
                l.SetValue("Color", red);

Please rate this post

Leave a Reply