Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function check()
- entry = tonumber(codeTbl[1]..codeTbl[2]..codeTbl[3]..codeTbl[4])
- if entry == code then mon.setCursorPos(1,10) print("ACCESS GRANTED") --do something here with redstone
- else mon.setCursorPos(1,10) print("ACCESS DENIED")
- end
- _1st = false
- _2nd = false
- _3rd = false
- _4th = false
- codeTbl = {}
- end
- function _123or4() --is it the 1st, 2nd, 3rd, or 4th number you pressed
- if _1st == false then mon.setCursorPos(11,2) _1st = true
- elseif _2nd == false then mon.setCursorPos(12,2) _2nd = true
- elseif _3rd == false then mon.setCursorPos(13,2) _3rd = true
- elseif _4th == false then mon.setCursorPos(14,2) _4th = true
- end
- end
- mon = peripheral.wrap("left")
- term.redirect(peripheral.wrap("left"))
- mon.setTextScale(.5)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- codeTbl = {} --table the code is hopefully being stored within
- _1st = false
- _2nd = false
- _3rd = false
- _4th = false
- code = 1234
- --read txt file and print it to monitor
- hFile = fs.open("keypad.txt", "r")
- for i = 1, 9 do
- print(hFile.readLine())
- end
- hFile.close()
- --it looks like this
- --/-\/-\/-\
- --|1||2||3|
- --\-/\-/\-/ ^^^^
- --/-\/-\/-\
- --|4||5||6|
- --\-/\-/\-/
- --/-\/-\/-\
- --|7||8||9|
- --\-/\-/\-/
- w,h = mon.getSize()
- repeat
- event,side,w,h = os.pullEvent("monitor_touch")
- if w == 1 or 2 or 3 and h == 1 or 2 or 3 then _123or4()
- print("1")
- elseif w == 4 or 5 or 6 and h == 1 or 2 or 3 then _123or4()
- print("2")
- elseif w == 7 or 8 or 9 and h == 1 or 2 or 3 then _123or4()
- print("3")
- elseif w == 1 or 2 or 3 and h == 4 or 5 or 6 then _123or4()
- print("4")
- elseif w == 4 or 5 or 6 and h == 4 or 5 or 6 then _123or4()
- print("5")
- elseif w == 7 or 8 or 9 and h == 4 or 5 or 6 then _123or4()
- print("6")
- elseif w == 1 or 2 or 3 and h == 7 or 8 or 9 then _123or4()
- print("7")
- elseif w == 4 or 5 or 6 and h == 7 or 8 or 9 then _123or4()
- print("8")
- elseif w == 7 or 8 or 9 and h == 7 or 8 or 9 then _123or4()
- print("9")
- end
- i = #codeTbl
- until i == 4
- if #codeTbl == 4 then check()
- end
Advertisement
Add Comment
Please, Sign In to add comment