SHOW:
|
|
- or go back to the newest paste.
1 | mon = peripheral.wrap("front") | |
2 | mon2 = peripheral.wrap("top") | |
3 | local password = { | |
4 | digit1 = "*", | |
5 | digit2 = "*", | |
6 | digit3 = "*", | |
7 | digit4 = "*" | |
8 | } | |
9 | mon.clear() | |
10 | mon.setCursorPos(2,1) | |
11 | mon.setBackgroundColor((colors.red)) | |
12 | mon.write("Reset")function writePad() | |
13 | local i = 1 | |
14 | local x = 2 | |
15 | local y = 2 | |
16 | ||
17 | while i <= 9 do | |
18 | mon.setBackgroundColor((colors.lime)) | |
19 | mon.setCursorPos(y,x) | |
20 | mon.write(i) | |
21 | mon.setCursorPos(y+1, x) | |
22 | mon.setBackgroundColor((colors.black)) | |
23 | mon.write(" ") | |
24 | y = y + 2 | |
25 | ||
26 | if y == 8 then | |
27 | y = 2 | |
28 | x = x + 1 | |
29 | end | |
30 | ||
31 | i = i + 1 | |
32 | end | |
33 | end | |
34 | writePad()mon.setBackgroundColor((colors.black)) | |
35 | function writePass() | |
36 | local pass = { | |
37 | pass1 = "_", | |
38 | pass2 = "_", | |
39 | pass3 = "_", | |
40 | pass4 = "_" | |
41 | } | |
42 | - | if password.digit1 ~= "*" then |
42 | + | if password.digit1 = "*" then |
43 | pass.pass1 = "*" | |
44 | - | endif password.digit2 ~= "*" then |
44 | + | endif password.digit2 = "*" then |
45 | pass.pass2 = "*" | |
46 | end | |
47 | - | if password.digit3 ~= "*" then |
47 | + | if password.digit3 = "*" then |
48 | pass.pass3 = "*" | |
49 | - | endif password.digit4 ~= "*" then |
49 | + | endif password.digit4 = "*" then |
50 | pass.pass4 = "*" | |
51 | end | |
52 | mon.setCursorPos(2,5) | |
53 | mon.write(pass.pass1..pass.pass2..pass.pass3..pass.pass4) | |
54 | endwritePass() | |
55 | ||
56 | local passPos = 1 | |
57 | local mousePosW = 1 | |
58 | local mousePosH = 1function setDigit(digit) | |
59 | if passPos == 1 then | |
60 | password.digit1 = digit | |
61 | end | |
62 | ||
63 | if passPos == 2 then | |
64 | password.digit2 = digit | |
65 | end | |
66 | ||
67 | if passPos == 3 then | |
68 | password.digit3 = digit | |
69 | end | |
70 | ||
71 | if passPos == 4 then | |
72 | password.digit4 = digit | |
73 | end | |
74 | passPos = passPos + 1 | |
75 | endfunction checkMousePos() | |
76 | if mousePosH == 1 then | |
77 | resetPass() | |
78 | end | |
79 | if mousePosH == 2 then | |
80 | ||
81 | if mousePosW == 2 or mousePosW == 3 then | |
82 | setDigit("1") | |
83 | end | |
84 | ||
85 | if mousePosW == 4 or mousePosW == 5 then | |
86 | setDigit("2") | |
87 | end | |
88 | ||
89 | if mousePosW == 6 or mousePosW == 7 then | |
90 | setDigit("3") | |
91 | end | |
92 | end | |
93 | ||
94 | if mousePosH == 3 then | |
95 | ||
96 | if mousePosW == 2 or mousePosW == 3 then | |
97 | setDigit("4") | |
98 | end | |
99 | ||
100 | if mousePosW == 4 or mousePosW == 5 then | |
101 | setDigit("5") | |
102 | end | |
103 | ||
104 | if mousePosW == 6 or mousePosW == 7 then | |
105 | setDigit("6") | |
106 | end | |
107 | end | |
108 | ||
109 | if mousePosH == 4 then | |
110 | ||
111 | if mousePosW == 2 or mousePosW == 3 then | |
112 | setDigit("7") | |
113 | end | |
114 | ||
115 | if mousePosW == 4 or mousePosW == 5 then | |
116 | setDigit("8") | |
117 | end | |
118 | ||
119 | if mousePosW == 6 or mousePosW == 7 then | |
120 | setDigit("9") | |
121 | end | |
122 | end | |
123 | ||
124 | endfunction resetPass() | |
125 | ||
126 | password.digit1 = "*" | |
127 | password.digit2 = "*" | |
128 | password.digit3 = "*" | |
129 | password.digit4 = "*" | |
130 | passPos = 1 | |
131 | writePass() | |
132 | end | |
133 | while true do | |
134 | if passPos == 5 then | |
135 | - | if password.digit1 == "9" and password.digit2 == "5" and password.digit3 == "4" and password.digit4 == "2" then -- this is where the actual password is hardcoded in |
135 | + | if password.digit1 == "9" and password.digit2 == "7" and password.digit3 == "4" and password.digit4 == "3" then -- this is where the actual password is hardcoded in |
136 | - | rs.setOutput("left", true) |
136 | + | rs.setOutput("right", true) |
137 | mon2.setCursorPos(1,1) | |
138 | mon2.clear() | |
139 | - | mon2.write("Welcome Herophantom") -- change this to whatever message you want |
139 | + | mon2.write("Welcome TheDroid_YT") -- change this to whatever message you want |
140 | - | sleep(4) |
140 | + | sleep(3) |
141 | - | rs.setOutput("left", false) |
141 | + | rs.setOutput("right", false) |
142 | resetPass() | |
143 | ||
144 | else | |
145 | local timer = 3 | |
146 | mon2.setTextColor(16384) | |
147 | while timer > 0 do | |
148 | mon2.setCursorPos(1,1) | |
149 | mon2.clear() | |
150 | - | mon2.write("Unauthorised Access Attempted") |
150 | + | mon2.write("Invalid Password") |
151 | sleep(0.5) | |
152 | mon2.setCursorPos(1,1) | |
153 | mon2.clear() | |
154 | sleep(0.5) | |
155 | timer = timer - 1 | |
156 | end | |
157 | resetPass() | |
158 | end | |
159 | end | |
160 | mon2.setTextColor(1) | |
161 | mon2.setCursorPos(1,1) | |
162 | mon2.clear() | |
163 | - | mon2.write("Authorised Personel Only") |
163 | + | mon2.write("Only Droid Permitted") |
164 | event,p1,p2,p3 = os.pullEvent() | |
165 | ||
166 | if event == "monitor_touch" then | |
167 | mousePosH = p3 | |
168 | mousePosW = p2 | |
169 | checkMousePos() | |
170 | endwritePass() | |
171 | end |