Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

JAMS - universal airlock script

Discussion in 'Programming Released Codes' started by Burillo, Oct 28, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Burillo Junior Engineer

    Messages:
    648
    JAMS Airlock Management System

    I've been wanting to tackle the airlock problem for a while now, in the same vein my other script (BARABAS) works - the least amount of configuration possible, the simplest operation imaginable. And i think i finally found a solution, and hereby present it to you.

    Want to set up airlocks, but don't want to either do everything manually or are discouraged by the idea of having a hundred timers? Don't know how to set up and airlock, but always wanted to try? Tired of your airlocks losing oxygen because setting up automatic depressurization is too complicated? Tired of other airlock scripts making you "tag" your blocks and engage in mass renaming? Look no further - JAMS will help you!

    JAMS is basically a fully automatic airlock script. Two airlock types are supported: a classic depressurization chamber-style airlock, and a hangar-style airlock.

    Depressurization chamber airlock

    Depressurization chamber's primary purpose is to allow people to enter/exit buildings while keeping pressure inside the building at all times. The only space that is ever depressurized is a small chamber separated by a door. To exit to space, walk up to the door (and trigger the sensor), the chamber is pressurized, the door opens, you enter the chamber, the door is closed behind you, the chamber is depressurized, the outer door opens and you exit to space. The same happens when coming from space, except everything is in reverse.

    So, depressurization chamber airlock is basically an airlock with two doors and an air vent(s) in between.To create an airlock like this, all you need to do is create two doors, two sensors and at least one air vent, and add them to a group with a name starting with "JAMS" (for example, "JAMS 1"). Lights are optional, everything else is mandatory. Then, set up your sensors, and you're done - everything else is taken care of by JAMS.

    How does it do its thing? Basically, it relies on heuristics. When it's first loaded, it doesn't know which door is your outer door, so it assumes every door is outer door and depressurizes the airlock by default. After first use, however, the script learns which door is the outer door, and depressurizes the inbetween space accordingly. How does it know which sensor corresponds to which door? The closest sensor to a door is considered belonging to that door. This basically means you don't have to configure anything other than grouping and sensor ranges - the script does everything else for you.

    Simple chamber airlock

    This airlock type is similar to depressurization chamber (in fact, almost identical), except that it doesn't require a vent in between. This is a "quick-n-dirty" airlock that doesn't care for keeping the oxygen.

    Hangar airlock

    Hangar-style airlocks work a little differently than the two above airlocks. While they can be used to create quick-n-dirty airlocks for personnel, their main purpose is to cover the pressurized hangar use case. The way they work is simple - any time a sensor is triggered, the room is depressurized and the doors are opened, until sensors are no longer active, after which the doors are closed and the room is pressurized again.

    Hangar airlocks can have any (non-zero) number of doors, any (non-zero) number of sensors, any (non-zero) number of air vents, and any number of lights (including none). Any active sensor will trigger depressurization, and the doors won't close until non of the sensors are active. To use this type of airlock, simply create your blocks and add them to a group with a name starting with "JAMS"

    Q&A

    Yes, JAMS will automatically detect which kind of airlock you have.

    No, it does not support sounds. If you think it's something worth looking into, please explain how you use sounds. I don't use them, so i have no idea what would be useful.

    Yes, you have to set up sensor ranges yourself.

    The lights will show green, yellow and red, depending on airlock state (when airlock is red, something went wrong, so it's ploughing through to finish what it started - JAMS will never ever get stuck). If you want lights to blink, set it up yourself.

    Yes, you read that right - you only need one programming block - for any number of airlocks! No complex trigger setups, no complicated timer logic, no naming conventions! Just name the groups differently - e.g. "JAMS Airlock 1", "JAMS Airlock 2", "JAMS it up your mom" etc.

    You're welcome to offer feedback and suggest features.


    Features
    • Can handle multiple airlocks at once, operating at the same time
    • Can handle three different types of airlocks
    • Fully automatic configuration (as long as you keep the airlock formats it was designed for) - you only need to set up sensor ranges and block groups
    • Enforced grid locality (JAMS groups from a non-local grid are ignored)
    • Optional light indication
    • Out-of-cycle door opening (meaning, JAMS will work correctly even if the door was open manually)
    • Flexible state machine, should work well on the biggest bases with dozens of airlocks

    How to install JAMS on your base/ship
    1. Create programmable block
    2. Paste the code into PB or subscribe to JAMS on workshop
    3. Create however many airlocks you like

    How to use depressurization chamber airlock
    1. Set up an outer door with a sensor as close as possible to the door, and set up sensor ranges
    2. Set up an inner door with a sensor as close as possible to the door, and set up sensor ranges
      • It is imperative to set up correct sensor ranges! Otherwise the script will work very flaky!
      • It is recommended to place the sensor right above the door, in which case the recommended sensor values are: 2-2-4-1-1-4
      • An alternative position for sensor is on the floor right in front of the door, in which case the recommended sensor values are 2-2-2-2-1-4
    3. Set up and connect an air vent between the doors
    4. Optionally add lights
    5. Add all of these blocks to the block group starting with "JAMS" (e.g. "JAMS 1")
    6. Repeat as necessary for any number of airlocks (each airlock should be a separate group)

    How to use simple chamber-style airlock

    1. Set up an outer door with a sensor as close as possible to the door, and set up sensor ranges
    2. Set up an inner door with a sensor as close as possible to the door, and set up sensor ranges
      • It is imperative to set up correct sensor ranges! Otherwise the script will work very flaky!
      • It is recommended to place the sensor right above the door, in which case the recommended sensor values are: 2-2-4-1-1-4
      • An alternative position for sensor is on the floor right in front of the door, in which case the recommended sensor values are 2-2-2-2-1-4
    3. Optionally add lights
    4. Add all of these blocks to the block group starting with "JAMS" (e.g. "JAMS 1")
    5. Repeat as necessary for any number of airlocks (each airlock should be a separate group)

    How to use hangar airlock
    1. Create a door (or lots of airtight hangar doors)
    2. Create sensors
    3. Set the sensors up (sensor ranges, trigger by ships, etc.)
    4. Create and connect an air vent inside the pressurized space
      • it may take a lot of time for a single air vent to pressurize/depressurize big spaces, so if your room/hangar is big, use a lot of them
      • make sure you have space for all that oxygen!
    5. Optionally add lights
    6. Add all of these blocks to the block group starting with "JAMS" (e.g. "JAMS 1")
    7. Repeat as necessary for any number of airlocks (each airlock should be a separate group)

    How to get

    Workshop link: http://steamcommunity.com/sharedfiles/filedetails/?id=760186546
    Code on github (stable version): https://raw.githubusercontent.com/burillo-se/JAMS/v1.2/JAMS.cs
    Code on github (latest version, may be buggy): https://raw.githubusercontent.com/burillo-se/JAMS/master/JAMS.cs

    Changelog
    • 21/4/2019 - v1.2 release:
      • New airlock type (vent-less chamber)
      • Fixed bug where airlock would get stuck if no room for oxygen
      • Improved output
      • Output to PB screen
    • 1/1/2018 - v1.13 release:
      • No longer requires timer
    • 17/2/2017 - v1.12 release:
      • Updated to latest PB API
    • 10/1/2016 - v1.11 release:
      • State is now preserved across world saves
      • Removed all timeouts from hangar airlock
    • 26/9/2016 - v1.1 release:
      • Numerous issues fixed
      • New airlock type supported
      • More crash resilience
      • Better grid locality algorithm
    • 30/6/2016 - v1.02 release:
      • Maintenance update, fix issues on latest SE version
    • 7/5/2016 - v1.01 release:
      • Doors aren't locking by default any more
      • Room is pressurized by default (seems to work faster)
      • Support for out-of-cycle door opening which doesn't trigger airlock
    • 3/5/2016 - v1.0 release:
      • Reworked the event loop, little chance of hitting instruction limits even on biggest bases with dozens of airlocks
      • Added support for light indication
      • On-the-fly updates (for example, it is now possible to add lights while the script is running)
      • Reliability improvements
    • 26/3/2016 - major rework:
      • Defaults to depressurization to prevent accidental oxygen loss
      • Reworked the event loop, multiple airlocks now work simultaneously
      • More reliable, watches pressurization levels instead of relying on timers
      • Saving data to Storage, so airlock state persists across server reboots
      • Door locking (to prevent accidental door openings)
      • Lockup protection (sometimes airvents don't depressurize, the script will force completion when that happens, resulting in some loss of oxygen)
     
    Last edited: Apr 21, 2019
    • Like Like x 2
  2. Burillo Junior Engineer

    Messages:
    648
    The script has received a major rework, it now works reliably and supports multiple airlocks at once.
     
  3. Burillo Junior Engineer

    Messages:
    648
    Version 1.0 is released. Due to a bug, i can't publish it on workshop yet, so please use the github link instead.

    Changes since last alphas:
    • Reworked the event loop, little chance of hitting instruction limits even on biggest bases with dozens of airlocks
    • Added support for light indication
    • On-the-fly updates (for example, it is now possible to add lights while the script is running)
    • Reliability improvements
    EDIT:

    1.01 released, added door override state (out-of-cycle door opening), also disabled door locking and pressurizing room by default
     
    Last edited: May 7, 2016
  4. Burillo Junior Engineer

    Messages:
    648
    release v1.02, maintenance update, to work with new SE version
     
  5. Burillo Junior Engineer

    Messages:
    648
  6. Burillo Junior Engineer

    Messages:
    648
    JAMS v1.1 has been released, main new feature is the new airlock type - hangar style airlock. Basically, if the sensor is triggered, the space will be depressurized and the door will be open.
     
  7. Burillo Junior Engineer

    Messages:
    648
    JAMS v1.11 has been released. Main new feature is save compatibility (meaning, state of airlocks is preserved on world save, instead of resetting).
     
  8. Burillo Junior Engineer

    Messages:
    648
    JAMS v1.12 released, updated to latest PB API.
     
  9. Burillo Junior Engineer

    Messages:
    648
    JAMS v1.13 released, timer is no longer is required.
     
  10. Burillo Junior Engineer

    Messages:
    648
    JAMS v1.2 released.
    - Added new airlock type (similar to chamber-style, but without the vents)
    - Improved output
    - Output to PB's own screen
    - Fixed a bug where airlock would get stuck when no room for oxygen in certain cases
     
Thread Status:
This last post in this thread was made more than 31 days old.