Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local accessCode = "147"
- local component = require("component")
- local sides = require("sides")
- local gpu = component.gpu
- local event = require("event")
- local ser = require("serialization")
- local term = require("term")
- local computer = component.computer
- local rs = component.redstone
- keypad = component.os_keypad
- alarm = component.os_alarm
- customButtons = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "<-", "0", "OK"}
- customButtonColor = {"1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "1", "3"}
- keypad.setKey(customButtons, customButtonColor)
- term.clear()
- print("MaksandraSecurity v1.0 [KeyPad Edition]")
- print("Система запущена.")
- alarm.setRange(150)
- local inputStr = ""
- while true do
- ev, address, button, button_label = event.pull("keypad")
- if ev then
- if button_label == "OK" then
- if inputStr == accessCode then
- term.write("Доступ разрешен!\n")
- inputStr = "OK!"
- keypad.setDisplay(inputStr)
- computer.beep()
- rs.setOutput(sides.down, 15)
- os.sleep(3)
- rs.setOutput(sides.down, 0)
- else
- term.write("Доступ запрещен!\n")
- inputStr = "Invalid!"
- alarm.activate()
- keypad.setDisplay(inputStr)
- os.sleep(3)
- alarm.deactivate()
- end
- inputStr = ""
- elseif button_label == "<-" then
- if string.len(inputStr) > 0 then
- tmpStr = string.sub(inputStr, 1 , string.len(inputStr) -1)
- inputStr = tmpStr
- end
- else
- inputStr = inputStr .. button_label
- end
- a = inputStr.len(inputStr)
- b = ""
- for i = a,1,-1
- do
- b = b .. "*"
- end
- keypad.setDisplay(b)
- end
- os.sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement