---- 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("bottom")
m1 = peripheral.wrap("top")
local commandBlock = peripheral.wrap("left")
currentCommand = commandBlock.getCommand()

m.setTextScale(0.5)
m1.clear()

while true do
m1.setBackgroundColor(colors.black)
m1.clear()
m.setBackgroundColor(colors.black)
m.clear()
m.setCursorPos(4,1)
m.setTextColor(colors.lime)
m.write("PASSWORD:")
term.redirect(m)
paintutils.drawLine(4,2,12,2,colors.red)
paintutils.drawLine(4,2,4,10,colors.red)
paintutils.drawLine(12,2,12,10,colors.red)
paintutils.drawLine(4,10,12,10,colors.red)
m.setBackgroundColor(colors.red)
m.setTextColor(colors.white)

function fillTable()
 btn.setTable("1", one, 6,6,4,4)
 btn.setTable("2", two, 8,8,4,4)
 btn.setTable("3", tre, 10,10,4,4) 
 btn.setTable("4", four, 6,6,6,6)
 btn.setTable("5", five, 8,8,6,6)
 btn.setTable("6", six, 10,10,6,6)
 btn.setTable("7", sev, 6,6,8,8)
 btn.setTable("8", eit, 8,8,8,8)
 btn.setTable("9", nin, 10,10,8,8)
 btn.screen()
end

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

function one()
 btn.flash("1")
 num1 = 1
end

function two()
 btn.flash("2")
 num1 = 2
end

function tre()
 btn.flash("3")
 num1 = 3
end

function four()
 btn.flash("4")
 num1 = 4
end 

function five()
 btn.flash("5")
 num1 = 5
end

function six()
 btn.flash("6")
 num1 = 6
end

function sev()
 btn.flash("7")
 num1 = 7
end

function eit()
 btn.flash("8")
 num1 = 8
end

function nin()
 btn.flash("9")
 num1 = 9
end

fillTable()

getClick()


function one()
 btn.flash("1")
 num2 = 1
end

function two()
 btn.flash("2")
 num2 = 2
end

function tre()
 btn.flash("3")
 num2 = 3
end

function four()
 btn.flash("4")
 num2 = 4
end

function five()
 btn.flash("5")
 num2 = 5
end

function six()
 btn.flash("6")
 num2 = 6
end

function sev()
 btn.flash("7")
 num2 = 7
end

function eit()
 btn.flash("8")
 num2 = 8
end

function nin()
 btn.flash("9")
 num2 = 9
end

fillTable()

getClick()

function one()
 btn.flash("1")
 num3 = 1
end

function two()
 btn.flash("2")
 num3 = 2
end

function tre()
 btn.flash("3")
 num3 = 3
end

function four()
 btn.flash("4")
 num3 = 4
end

function five()
 btn.flash("5")
 num3 = 5
end

function six()
 btn.flash("6")
 num3 = 6
end

function sev()
 btn.flash("7")
 num3 = 7
end

function eit()
 btn.flash("8")
 num3 = 8
end

function nin()
 btn.flash("9")
 num3 = 9
end

fillTable()

getClick()

m1.setTextScale(1)

if num1 == 1 and num2 == 2 and num3 == 3 then -- change your password here
m1.setBackgroundColor(colors.green)
m1.clear()
m1.setCursorPos(14,3)
m1.write("ACESS GRANTED!")
rs.setOutput("back", true)
commandBlock.setCommand("playsound wizard.access_granted @a")
commandBlock.runCommand()
sleep(6)
rs.setOutput("back", false)

else

m1.setBackgroundColor(colors.red)
m1.clear()
m1.setCursorPos(14,3)
m1.write("ACESS DENIED!")
commandBlock.setCommand("playsound wizard.access_denied @a")
commandBlock.runCommand()
sleep(4)
end


end
