Posted 21 July 2014 - 09:50 PM
Hello
Im trying to create an airlock controlled by 2 computers
when computer 1 opens the door then you cant close the door with computer 2
Same counts the other way around, if computer 2 opens the door then computer 1 cant do anything with it.
I use bundledcable with this.
White cable is to open/close door
Yellow cable is to flow water between the doors (airlock)
both computers are connected to the same bundled cable.
Im trying to create an airlock controlled by 2 computers
when computer 1 opens the door then you cant close the door with computer 2
Same counts the other way around, if computer 2 opens the door then computer 1 cant do anything with it.
I use bundledcable with this.
White cable is to open/close door
Yellow cable is to flow water between the doors (airlock)
both computers are connected to the same bundled cable.
-- ######################
-- ## CABLE USAGE
-- ######################
-- Computer ID 11
-- Waterflow yellow
-- Door white
-- ######################
-- ##
-- ######################
os.pullEvent = os.pullEventRaw
local standby = 5
local side = "back"
local password = "sushi"
local YES = "y"
local back = "back"
local a = "1"
local b = "2"
local c = "3"
-- ######################
-- ##
-- ######################
local width, height = term.getSize()
while true do
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.black)
term.clear()
term.setTextColor(colors.white)
term.setBackgroundColor(colors.red)
term.clearLine()
term.setCursorPos(1, height)
term.clearLine()
local text = "D1 Airlock Controlpanel"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)
-- ######################
-- #### MENU
-- ######################
term.setTextColor(colors.white)
term.setBackgroundColor(colors.black)
term.setCursorPos(1, 3)
term.write("|D1 Menu|")
term.setCursorPos(4, 5)
term.write("1 - Open D1 Airlock")
term.setCursorPos(4, 6)
term.write("2 - Close D1 Airlock")
term.setTextColor(colors.red)
term.setBackgroundColor(colors.black)
term.setCursorPos(4, 7)
term.setTextColor(colors.red)
term.setBackgroundColor(colors.black)
term.setCursorPos(4, 14)
term.setTextColor(colors.white)
term.write("Option: ")
local input = read()
-- ######################
-- #### DOORS OPEN
-- ######################
if input == a then
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.black)
term.clear()
term.setTextColor(colors.white)
term.setBackgroundColor(colors.red)
term.clearLine()
term.setCursorPos(1, height)
term.clearLine()
local text = "D1 Airlock"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)
-- ####
term.setCursorPos(3, 3)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.write("Opening D1 Airlock")
for i=1, 1 do
rs.setBundledOutput("back", colours.yellow)
sleep(6.5)
rs.setBundledOutput("back", colors.yellow+colors.white)
sleep(0.5)
end
term.setCursorPos(25, 3)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.lime)
term.write("READY")
sleep(2)
term.clear()
end
-- ######################
-- #### DOORS CLOSE
-- ######################
if input == b then
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.black)
term.clear()
term.setTextColor(colors.white)
term.setBackgroundColor(colors.red)
term.clearLine()
term.setCursorPos(1, height)
term.clearLine()
local text = "D1 Airlock"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)
term.setCursorPos(3, 3)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.write("Closing D1 Airlock")
for i=1, 1 do
rs.setBundledOutput("back", colors.yellow+colors.black)
sleep(1.5)
rs.setBundledOutput("back", colours.black)
end
term.setCursorPos(25, 3)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.lime)
term.write("READY")
sleep(2)
term.clear()
end
end
Edited on 21 July 2014 - 07:51 PM