Rolcam

Computercraft - Airlock Controller Program

Feb 2nd, 2022 (edited)
1,462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1. --[[
  2. Galacticraft Airlock Controller Program V1
  3. This program is designed for use in Tekkit (Galacticraft, MineFactory Reloaded*, & Computercraft mods required)
  4.  
  5. *or any mod that uses colored channels for redstone wiring (e.g. bundled cables from "ProjectRed - Transmission")
  6.  
  7. Wiring Guide:
  8. Outputs:
  9.     White Channel: Inner Air Lock (set controller to open on redstone signal)
  10.     Orange Channel: Outer Air Lock (set controller to open on redstone signal)
  11.     Light Blue Channel: Piston (to shut off/on the oxygen sealer - I placed this below the airlock and used iron bars as a vent
  12. Inputs:
  13.     Magenta: Button (to cycle airlock)
  14.  
  15. Important: Please create a program called .config on the computer. Put anything into line 1 of it and save it. This will serve as a storage of the air lock's state. This will get overwritten as the air lock cycles. It defaults to an oxygen sealed state (inner air lock opened, outer air lock sealed)
  16. ]]--
  17.  
  18. -- Variables
  19. status = "Compressed"
  20. test = false
  21. -- Initial Check
  22. if not fs.exists(".config") then
  23.     status = "unsafe"
  24. else
  25.     data = fs.open(".config", "r")
  26.     status = data.readLine()
  27.     data.close()
  28.     rs.setBundledOutput("back", colors.combine(colors.white, colors.orange, colors.lightBlue))
  29. end
  30.  
  31. while true do
  32.     data = fs.open(".config", "r")
  33.     status = data.readLine()
  34.     data.close()
  35.     -- Stops the program if the airlock config file doesn't exist
  36.     if status == "unsafe" then
  37.         break
  38.     end
  39.     if status == "Decompressed" then
  40.         rs.setBundledOutput("back", colors.combine(colors.white, colors.orange, colors.lightBlue))
  41.         rs.setOutput("left", true)
  42.         rs.setOutput("right", true)
  43.         sleep(2)
  44.         rs.setBundledOutput("back", colors.combine(colors.white, colors.orange))
  45.         sleep(2)
  46.         rs.setBundledOutput("back", colors.orange)
  47.         data = fs.open(".config", "w")
  48.         data.writeLine("Compressed")
  49.         data.close()
  50.         rs.setOutput("left", false)
  51.         rs.setOutput("right", false)
  52.     else
  53.         rs.setBundledOutput("back", colors.combine(colors.white,colors.orange))
  54.         rs.setOutput("left", true)
  55.         rs.setOutput("right", true)
  56.         sleep(2)
  57.         rs.setBundledOutput("back", colors.combine(colors.white, colors.orange, colors.lightBlue))
  58.         sleep(2)
  59.         rs.setBundledOutput("back", colors.combine(colors.white, colors.lightBlue))
  60.         data = fs.open(".config", "w")
  61.         data.writeLine("Decompressed")
  62.         data.close()
  63.         rs.setOutput("left", false)
  64.         rs.setOutput("right", false)
  65.     end
  66.     while rs.testBundledInput("back", colors.magenta) == false do
  67.         sleep(0.1)
  68.     end            
  69. end
  70.    
Add Comment
Please, Sign In to add comment