View difference between Paste ID: z0dPqXvk and D9bbvmfH
SHOW: | | - or go back to the newest paste.
1
--Hier wird das Passwort eingestellt !
2
--Du setzt für die Zahl die du drücken willst einfach 1;2;3;4 ein und legst so auch direkt die Reihenfolge fest.
3
--Bei allen Restlichen Zahlen MUSS eine 0 stehen.
4
5-
Passwort1 = 1
5+
Passwort1 = 4
6-
Passwort2 = 2
6+
Passwort2 = 3
7-
Passwort3 = 3
7+
Passwort3 = 0
8-
Passwort4 = 4
8+
Passwort4 = 0
9-
Passwort5 = 0
9+
Passwort5 = 2
10-
Passwort6 = 0
10+
Passwort6 = 1
11
Passwort7 = 0
12
Passwort8 = 0
13
Passwort9 = 0
14
15
-- Zeit solange die Tür geöffnet ist
16
17
local Zeit2 = 3
18
19
-- Anzahl der Versuche
20
21
local Anzahl = 5
22
23
-- Zeit die das Programm wartet nach den Versuchen
24
25
local Zeit = 20
26
27
-- Animaion nach Passworteingabe, bei kleinem Monitor besser ausschalten    (an true ; aus false) (anzahl meint die Dauer der Animation)
28
29
animation = true
30
anzahl = 7
31
-- -- -- -- -- -- -- -- -- -- -- -- 
32
33
34
35
local count = 0
36
local count2 = 0
37
a = 0
38
39
m = peripheral.wrap("top")
40
m.setBackgroundColor(128)
41
function draw()
42
m.clear()
43
m.setCursorPos(1,1)
44
m.setTextScale(1.5)
45
m.write("1")
46
m.setCursorPos(3,1)
47
m.write("2")
48
m.setCursorPos(5,1)
49
m.write("3")
50
m.setCursorPos(1,2)
51
m.write("4")
52
m.setCursorPos(3,2)
53
m.write("5")
54
m.setCursorPos(5,2)
55
m.write("6")
56
m.setCursorPos(1,3)
57
m.write("7")
58
m.setCursorPos(3,3)
59
m.write("8")
60
m.setCursorPos(5,3)
61
m.write("9")
62
end
63
draw()
64
65
 
66
while true do
67
  event,side,x,y = os.pullEvent()
68
  if event == "monitor_touch" then
69
    count = count+1
70
    if x == 1 and y == 1 and count == Passwort1 then
71
      a = a+Passwort1
72
    end
73
    if x == 3 and y == 1 and count == Passwort2 then
74
      a = a+Passwort2
75
    end
76
    if x == 5 and y == 1 and count == Passwort3 then
77
      a = a+Passwort3
78
    end
79
    if x == 1 and y == 2 and count == Passwort4 then
80
      a = a+Passwort4
81
    end
82
    if x == 3 and y == 2 and count == Passwort5 then
83
      a = a+Passwort5
84
    end
85
    if x == 5 and y == 2 and count == Passwort6 then
86
      a = a+Passwort6
87
    end
88
    if x == 1 and y == 3 and count == Passwort7 then
89
      a = a+Passwort7
90
    end
91
    if x == 3 and y == 3 and count == Passwort8 then
92
      a = a+Passwort8
93
    end
94
    if x == 5 and y == 3 and count == Passwort9 then
95
      a = a+Passwort9
96
    end
97
	
98
	
99
	if count == 1 then
100
		m.setBackgroundColor(128)
101
		m.setCursorPos(1,4)
102
		m.write("*")
103
	end
104
	if count == 2 then
105
		m.setBackgroundColor(128)
106
		m.setCursorPos(2,4)
107
		m.write("*")
108
	end
109
	if count == 3 then
110
		m.setBackgroundColor(128)
111
		m.setCursorPos(3,4)
112
		m.write("*")
113
	end
114
	if count == 4 then
115
		m.setBackgroundColor(128)
116
		m.setCursorPos(4,4)
117
		m.write("*")
118
		sleep(0.8)
119
		
120
		-- Animation
121
		
122
		count3 = 0
123
		
124
		while count3 < anzahl and animation == true do
125
		m.setCursorPos(5,4)
126
		m.write("/")
127
		sleep(0.3)
128
		m.setCursorPos(5,4)
129
		m.write("|")
130
		sleep(0.3)
131
		
132
		count3 = count3 + 1
133
		end
134
		
135
		
136
	end
137
	
138
			-- Richtiges Passwort
139
	
140
    if a == 10 and count == 4 then
141
    
142
		a      = 0 --Variable zum Berechnen 
143
		count  = 0 --Anzahl der Versuche
144
		count2 = 0 --Anzahl der Fehlversuche
145
		
146
    m.setBackgroundColor(colors.green)
147
    draw()
148
	m.setCursorPos(1,4)
149
	m.write(" OK ")
150
    rs.setOutput("left",true)
151
    sleep(Zeit2)
152
    m.setBackgroundColor(128)
153
    draw()
154
    rs.setOutput("left",false)
155
	
156
			--  Falsches Passwort
157
	
158
		elseif count == 4 then
159
		a = 0
160
		count = 0
161
		
162
		
163
		
164
		m.setBackgroundColor(colors.red)
165
		draw()
166
		m.setCursorPos(1,4)
167
		m.write("Wrong")
168
		sleep(2)		
169
		m.setBackgroundColor(128)
170
		
171
		count2 = count2 + 1
172
		
173
		-- Ausgabe für die verbleibende Anzahl an Versuchen 
174
		
175
		
176
		
177
		if Anzahl - count2 > 0 then		
178
		m.clear()
179
		m.setTextScale(0.5)
180
		m.setBackgroundColor(128)
181
		m.setCursorPos(3,2)
182
		rechnung = Anzahl - count2
183
		if rechnung > 1 then
184
		m.write(""..rechnung.."")
185
		m.setCursorPos(1,3)
186
		m.write("Versuche")
187
		m.setCursorPos(1,4)
188
		m.write("verbleibend")
189
		end
190
		if rechnung == 1 then
191
		m.write(""..rechnung.."")
192
		m.setCursorPos(1,3)
193
		m.write("Versuch")
194
		m.setCursorPos(1,4)
195
		m.write("verbleibend")
196
		end
197
				
198
		sleep(5)
199
		draw()
200
		end
201
		
202
		
203
		
204
		
205
		
206
		-- Zugang verwehrt
207
		
208
		m.setBackgroundColor(colors.black)
209
		if count2 == Anzahl then 
210
		
211
		m.clear()
212
		
213
		count2 = 0
214
		
215
		m.setBackgroundColor(colors.black)
216
		m.setTextScale(1)
217
		m.setCursorPos(1,4)
218
		m.write("Access")
219
		m.setCursorPos(1,5)
220
		m.write("Denied")
221
		sleep(Zeit)
222
		m.setTextScale(1.5)
223
		m.setBackgroundColor(128)
224
		draw()
225
		
226
		end
227
		
228
		
229
		end        
230
  end
231
end