---- Super Security Door, By Gustavo Wizard, @2014
---- This program needs Direwolf20 Button API
---- This program needs 2 monitors (bottom 1x1 and top 3x1) 
---- Plz give credit for me and for the button API author if using this program in any way


os.loadAPI("btn")
m = peripheral.wrap("top")
--rednet.open("front")

m.setTextScale(0.5)

while true do
m.setBackgroundColor(colors.black)
m.clear()

-- Lights and Alert Controls
m.setCursorPos(3,1)
m.setTextColor(colors.white)
m.write("BASE LIGHTS:")
term.redirect(m)
paintutils.drawLine(2,3,14,3,colors.yellow)
paintutils.drawLine(2,13,14,13,colors.yellow)
paintutils.drawLine(2,3,2,13,colors.yellow)
paintutils.drawLine(14,3,14,13,colors.yellow)
m.setBackgroundColor(colors.red)
m.setTextColor(colors.white)

function fillTable()
 btn.setTable("NORMAL", nor, 4,12,5,5)
 btn.setTable("RED S", red, 4,12,7,7)
 btn.setTable("ALERT!", ale, 4,12,9,9)
 btn.setTable("OFF", off, 4,12,11,11)
 btn.screen()
end

function getClick()
 event,side,x,y = os.pullEvent("monitor_touch")
 btn.checkxy(x,y)
end

function nor()
 rs.setOutput("right", true)
 rs.setOutput("left", false)
 rs.setOutput("bottom", false)
end

function red()
 rs.setOutput("right", false)
 rs.setOutput("left", true)
 rs.setOutput("bottom", false)
end

function ale()
 rs.setOutput("right", false)
 rs.setOutput("left", true)
 rs.setOutput("bottom", true)
end

function off()
 rs.setOutput("right", false)
 rs.setOutput("left", false)
 rs.setOutput("bottom", false)
end

fillTable()

getClick()

--local id, message = rednet.receive()
--if message == "nor" and id == 6 then
-- rs.setOutput("right", true)
-- rs.setOutput("left", false)
-- rs.setOutput("back", false)
--end
--if message == "red" and id == 6 then
-- rs.setOutput("right", false)
 

end

