SHOW:
|
|
- or go back to the newest paste.
1 | - | local accessCode = "147" |
1 | + | local accessCode = "147" |
2 | - | |
2 | + | |
3 | - | local component = require("component") |
3 | + | local component = require("component") |
4 | - | local sides = require("sides") |
4 | + | local sides = require("sides") |
5 | - | local gpu = component.gpu |
5 | + | local gpu = component.gpu |
6 | - | local event = require("event") |
6 | + | local event = require("event") |
7 | - | local ser = require("serialization") |
7 | + | local ser = require("serialization") |
8 | - | local term = require("term") |
8 | + | local term = require("term") |
9 | - | local computer = component.computer |
9 | + | local computer = component.computer |
10 | - | local rs = component.redstone |
10 | + | local rs = component.redstone |
11 | - | keypad = component.os_keypad |
11 | + | keypad = component.os_keypad |
12 | - | alarm = component.os_alarm |
12 | + | alarm = component.os_alarm |
13 | - | |
13 | + | |
14 | - | customButtons = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "<-", "0", "OK"} |
14 | + | customButtons = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "<-", "0", "OK"} |
15 | - | customButtonColor = {"1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "1", "3"} |
15 | + | customButtonColor = {"1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "1", "3"} |
16 | - | keypad.setKey(customButtons, customButtonColor) |
16 | + | keypad.setKey(customButtons, customButtonColor) |
17 | - | |
17 | + | |
18 | - | term.clear() |
18 | + | term.clear() |
19 | - | print("MaksandraSecurity v1.0 [KeyPad Edition]") |
19 | + | print("MaksandraSecurity v1.0 [KeyPad Edition]") |
20 | - | print("Система запущена.") |
20 | + | print("Система запущена.") |
21 | - | alarm.setRange(150) |
21 | + | alarm.setRange(150) |
22 | - | local inputStr = "" |
22 | + | local inputStr = "" |
23 | - | while true do |
23 | + | while true do |
24 | - | ev, address, button, button_label = event.pull("keypad") |
24 | + | ev, address, button, button_label = event.pull("keypad") |
25 | - | if ev then |
25 | + | if ev then |
26 | - | if button_label == "OK" then |
26 | + | if button_label == "OK" then |
27 | - | if inputStr == accessCode then |
27 | + | if inputStr == accessCode then |
28 | - | term.write("Доступ разрешен!\n") |
28 | + | term.write("Доступ разрешен!\n") |
29 | - | inputStr = "Welcome!" |
29 | + | inputStr = "OK!" |
30 | - | keypad.setDisplay(inputStr) |
30 | + | keypad.setDisplay(inputStr) |
31 | - | computer.beep() |
31 | + | computer.beep() |
32 | - | rs.setOutput(sides.down, 15) |
32 | + | rs.setOutput(sides.down, 15) |
33 | - | os.sleep(3) |
33 | + | os.sleep(3) |
34 | - | rs.setOutput(sides.down, 0) |
34 | + | rs.setOutput(sides.down, 0) |
35 | - | else |
35 | + | else |
36 | - | term.write("Доступ запрещен!\n") |
36 | + | term.write("Доступ запрещен!\n") |
37 | - | inputStr = "Error!" |
37 | + | inputStr = "Invalid!" |
38 | - | alarm.activate() |
38 | + | alarm.activate() |
39 | - | keypad.setDisplay(inputStr) |
39 | + | keypad.setDisplay(inputStr) |
40 | - | os.sleep(3) |
40 | + | os.sleep(3) |
41 | - | alarm.deactivate() |
41 | + | alarm.deactivate() |
42 | - | end |
42 | + | end |
43 | - | inputStr = "" |
43 | + | inputStr = "" |
44 | - | elseif button_label == "<-" then |
44 | + | elseif button_label == "<-" then |
45 | - | if string.len(inputStr) > 0 then |
45 | + | if string.len(inputStr) > 0 then |
46 | - | tmpStr = string.sub(inputStr, 1 , string.len(inputStr) -1) |
46 | + | tmpStr = string.sub(inputStr, 1 , string.len(inputStr) -1) |
47 | - | inputStr = tmpStr |
47 | + | inputStr = tmpStr |
48 | - | end |
48 | + | end |
49 | - | else |
49 | + | else |
50 | - | inputStr = inputStr .. button_label |
50 | + | inputStr = inputStr .. button_label |
51 | - | end |
51 | + | end |
52 | - | keypad.setDisplay(inputStr) |
52 | + | a = inputStr.len(inputStr) |
53 | - | end |
53 | + | b = "" |
54 | - | os.sleep(0) |
54 | + | for i = a,1,-1 |
55 | do | |
56 | b = b .. "*" | |
57 | end | |
58 | keypad.setDisplay(b) | |
59 | end | |
60 | os.sleep(0) | |
61 | end |