Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("top")
- mon.setBackgroundColor(colors.blue)
- mon.clear()
- local function keypad(x, y)
- x = x or 3
- y = y or 2
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.lightGray)
- mon.setCursorPos(x, y)
- mon.write("123")
- mon.setCursorPos(x, y+1)
- mon.write("456")
- mon.setCursorPos(x, y+2)
- mon.write("789")
- mon.setTextColor(colors.red)
- mon.setCursorPos(x, y+3)
- mon.write("<")
- mon.setTextColor(colors.black)
- mon.write("0")
- mon.setTextColor(colors.lime)
- mon.write("/")
- end
- local function digits(dT)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(2, 1)
- mon.write(dT..string.rep(" ", 5-#dT))
- end
- local digitsTyped = ""
- local pad = {
- {1, 2, 3},
- {4, 5, 6},
- {7, 8, 9},
- {"<", 0, "/"}
- }
- local function verify()
- if digitsTyped == "12345" then
- loop = acc
- print("HELLO")
- else
- mon.setCursorPos(2, 1)
- mon.setTextColor(colors.red)
- print(digitsTyped)
- mon.write("WRONG")
- sleep(4)
- digitsTyped = ""
- end
- end
- local function touch(x, y)
- local _x = 3 -- to 5
- local _y = 2 -- to 5
- if x < _x or x > 5 or y < _y or y > 5 then
- return
- end
- local d = pad[y-1][x-2]
- if d == "<" then
- digitsTyped = digitsTyped:sub(1, -2)
- elseif d == "/" then
- verify()
- else
- if #digitsTyped < 5 then
- digitsTyped = digitsTyped..d
- end
- end
- end
- keypad()
- local function login()
- digits(digitsTyped)
- local e, p1, p2, p3, p4 = os.pullEvent()
- if e == "monitor_touch" and p1 == "top" then
- touch(p2, p3)
- end
- end
- local function acc()
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.lime)
- mon.clear()
- mon.setCursorPos(2, 2)
- mon.write("VERIFIED")
- end
- local loop = login
- while true do
- loop()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement