--os.loadAPI("ocs/apis/sensor")
rednet.open("bottom")
local monitor = peripheral.wrap("top")
--prox = sensor.wrap("left")
term.clear()

monitor.setBackgroundColor(colors.black)
monitor.clear()
monitor.setTextColor(colors.lightBlue)
monitor.setCursorPos(8,1)
monitor.write("Oxygen Central")
monitor.setTextColor(colors.white)
monitor.setCursorPos(1,3)
monitor.write("Control Tower")
monitor.setCursorPos(1,4)
monitor.write("Main Section")
monitor.setCursorPos(1,5)
monitor.write("Nuclear Core")
monitor.setCursorPos(1,6)
monitor.write("Green House")
monitor.setCursorPos(1,7)
monitor.write("Base Stargate")
monitor.setCursorPos(1,8)
monitor.write("Launching Pad")
monitor.setCursorPos(1,9)
monitor.write("Living Rooms")
monitor.setCursorPos(1,10)
monitor.write("Science Dept.")
monitor.setCursorPos(1,11)
monitor.write("FREE SLOT")
monitor.setCursorPos(1,12)
monitor.write("FREE SLOT")
--monitor.write("------------------------------------")
term.setCursorPos(1,1)
print("OXYGEN SYSTEMS")

while true do

-- Control Tower

if rs.getInput("right") == true then 
 monitor.setCursorPos(15,3)
 monitor.setBackgroundColor(colors.lime)
 monitor.write("ON ")
end

if rs.getInput("right") == false then
 monitor.setCursorPos(15,3)
 monitor.setBackgroundColor(colors.red)
 monitor.write("OFF")
end

-- Main Room

local id, message = rednet.receive()
if message == "o1" and id == 9 then
 monitor.setCursorPos(15,4)
 monitor.setBackgroundColor(colors.cyan)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o1n" and id == 9 then
 monitor.setCursorPos(15,4)
 monitor.setBackgroundColor(colors.orange)
 monitor.write("OFF")
end

local id, message = rednet.receive()
if message == "o2" and id == 19 then
 monitor.setCursorPos(15,5)
 monitor.setBackgroundColor(colors.lime)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o2n" and id == 19 then
 monitor.setCursorPos(15,5)
 monitor.setBackgroundColor(colors.red)
 monitor.write("OFF")
end

local id, message = rednet.receive()
if message == "o3" and id == 12 then
 monitor.setCursorPos(15,6)
 monitor.setBackgroundColor(colors.cyan)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o3n" and id == 12 then
 monitor.setCursorPos(15,6)
 monitor.setBackgroundColor(colors.orange)
 monitor.write("OFF")
end

local id, message = rednet.receive()
if message == "o4" and id == 28 then
 monitor.setCursorPos(15,7)
 monitor.setBackgroundColor(colors.lime)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o4n" and id == 28 then
 monitor.setCursorPos(15,7)
 monitor.setBackgroundColor(colors.red)
 monitor.write("OFF")
end

local id, message = rednet.receive()
if message == "o5" and id == 33 then
 monitor.setCursorPos(15,8)
 monitor.setBackgroundColor(colors.cyan)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o5n" and id == 33 then
 monitor.setCursorPos(15,8)
 monitor.setBackgroundColor(colors.orange)
 monitor.write("OFF") 
end      

local id, message = rednet.receive()
if message == "o6" and id == 36 then
 monitor.setCursorPos(15,9)
 monitor.setBackgroundColor(colors.lime)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o6n" and id == 36 then
 monitor.setCursorPos(15,9)
 monitor.setBackgroundColor(colors.red)
 monitor.write("OFF")
end

local id, message = rednet.receive()
if message == "o7" and id == 37 then
 monitor.setCursorPos(15,10)
 monitor.setBackgroundColor(colors.cyan)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o7n" and id == 37 then
 monitor.setCursorPos(15,10)
 monitor.setBackgroundColor(colors.orange)
 monitor.write("OFF")
end

local id, message = rednet.receive()
if message == "o8" and id == 85 then
 monitor.setCursorPos(15,11)
 monitor.setBackgroundColor(colors.lime)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o8n" and id == 85 then
 monitor.setCursorPos(15,11)
 monitor.setBackgroundColor(colors.red)
 monitor.write("OFF")
end

local id, message = rednet.receive()
if message == "o9" and id == 86 then
 monitor.setCursorPos(15,12)
 monitor.setBackgroundColor(colors.cyan)
 monitor.write("ON ")
end

local id, message = rednet.receive()
if message == "o9n" and id == 86 then
 monitor.setCursorPos(15,12)
 monitor.setBackgroundColor(colors.orange)
 monitor.write("OFF")
end


--local id, message = rednet.receive()

--moreDetails = prox.getTargetDetails("6,-8,1")
--monitor.setCursorPos(12,18)
--monitor.setBackgroundColor(colors.black)
--monitor.write(moreDetails.Active)
--monitor.setCursorPos(12,19)
--monitor.write(moreDetails.Heat)

end

