Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Hier wird das Passwort eingestellt !
- --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.
- --Bei allen Restlichen Zahlen MUSS eine 0 stehen.
- Passwort1 = 1
- Passwort2 = 2
- Passwort3 = 3
- Passwort4 = 4
- Passwort5 = 0
- Passwort6 = 0
- Passwort7 = 0
- Passwort8 = 0
- Passwort9 = 0
- -- Zeit solange die Tür geöffnet ist
- local Zeit2 = 3
- -- Anzahl der Versuche
- local Anzahl = 5
- -- Zeit die das Programm wartet nach den Versuchen
- local Zeit = 20
- -- Animaion nach Passworteingabe, bei kleinem Monitor besser ausschalten (an true ; aus false) (anzahl meint die Dauer der Animation)
- animation = true
- anzahl = 7
- -- -- -- -- -- -- -- -- -- -- -- --
- local count = 0
- local count2 = 0
- a = 0
- m = peripheral.wrap("top")
- m.setBackgroundColor(128)
- function draw()
- m.clear()
- m.setCursorPos(1,1)
- m.setTextScale(1.5)
- m.write("1")
- m.setCursorPos(3,1)
- m.write("2")
- m.setCursorPos(5,1)
- m.write("3")
- m.setCursorPos(1,2)
- m.write("4")
- m.setCursorPos(3,2)
- m.write("5")
- m.setCursorPos(5,2)
- m.write("6")
- m.setCursorPos(1,3)
- m.write("7")
- m.setCursorPos(3,3)
- m.write("8")
- m.setCursorPos(5,3)
- m.write("9")
- end
- draw()
- while true do
- event,side,x,y = os.pullEvent()
- if event == "monitor_touch" then
- count = count+1
- if x == 1 and y == 1 and count == Passwort1 then
- a = a+Passwort1
- end
- if x == 3 and y == 1 and count == Passwort2 then
- a = a+Passwort2
- end
- if x == 5 and y == 1 and count == Passwort3 then
- a = a+Passwort3
- end
- if x == 1 and y == 2 and count == Passwort4 then
- a = a+Passwort4
- end
- if x == 3 and y == 2 and count == Passwort5 then
- a = a+Passwort5
- end
- if x == 5 and y == 2 and count == Passwort6 then
- a = a+Passwort6
- end
- if x == 1 and y == 3 and count == Passwort7 then
- a = a+Passwort7
- end
- if x == 3 and y == 3 and count == Passwort8 then
- a = a+Passwort8
- end
- if x == 5 and y == 3 and count == Passwort9 then
- a = a+Passwort9
- end
- if count == 1 then
- m.setBackgroundColor(128)
- m.setCursorPos(1,4)
- m.write("*")
- end
- if count == 2 then
- m.setBackgroundColor(128)
- m.setCursorPos(2,4)
- m.write("*")
- end
- if count == 3 then
- m.setBackgroundColor(128)
- m.setCursorPos(3,4)
- m.write("*")
- end
- if count == 4 then
- m.setBackgroundColor(128)
- m.setCursorPos(4,4)
- m.write("*")
- sleep(0.8)
- -- Animation
- count3 = 0
- while count3 < anzahl and animation == true do
- m.setCursorPos(5,4)
- m.write("/")
- sleep(0.3)
- m.setCursorPos(5,4)
- m.write("|")
- sleep(0.3)
- count3 = count3 + 1
- end
- end
- -- Richtiges Passwort
- if a == 10 and count == 4 then
- a = 0 --Variable zum Berechnen
- count = 0 --Anzahl der Versuche
- count2 = 0 --Anzahl der Fehlversuche
- m.setBackgroundColor(colors.green)
- draw()
- m.setCursorPos(1,4)
- m.write(" OK ")
- rs.setOutput("left",true)
- sleep(Zeit2)
- m.setBackgroundColor(128)
- draw()
- rs.setOutput("left",false)
- -- Falsches Passwort
- elseif count == 4 then
- a = 0
- count = 0
- m.setBackgroundColor(colors.red)
- draw()
- m.setCursorPos(1,4)
- m.write("Wrong")
- sleep(2)
- m.setBackgroundColor(128)
- count2 = count2 + 1
- -- Ausgabe für die verbleibende Anzahl an Versuchen
- if Anzahl - count2 > 0 then
- m.clear()
- m.setTextScale(0.5)
- m.setBackgroundColor(128)
- m.setCursorPos(3,2)
- rechnung = Anzahl - count2
- if rechnung > 1 then
- m.write(""..rechnung.."")
- m.setCursorPos(1,3)
- m.write("Versuche")
- m.setCursorPos(1,4)
- m.write("verbleibend")
- end
- if rechnung == 1 then
- m.write(""..rechnung.."")
- m.setCursorPos(1,3)
- m.write("Versuch")
- m.setCursorPos(1,4)
- m.write("verbleibend")
- end
- sleep(5)
- draw()
- end
- -- Zugang verwehrt
- m.setBackgroundColor(colors.black)
- if count2 == Anzahl then
- m.clear()
- count2 = 0
- m.setBackgroundColor(colors.black)
- m.setTextScale(1)
- m.setCursorPos(1,4)
- m.write("Access")
- m.setCursorPos(1,5)
- m.write("Denied")
- sleep(Zeit)
- m.setTextScale(1.5)
- m.setBackgroundColor(128)
- draw()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement