Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 1.1.1
- function yNt()
- local n=1
- while true do
- local x, y=term.getCursorPos()
- term.clearLine()
- if n==1 then write(">No< Yes") else write (" No >Yes<") end
- term.setCursorPos(x, y)
- a, b=os.pullEvent("key")
- if b==263 and n==2 then n=1 end
- if b==262 and n==1 then n=2 end
- if b==257 then
- print("")
- if n==1 then return false end
- if n==2 then return true end
- end
- end
- end
- function Menu()
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColour(colours.green)
- write("exit ")
- term.setTextColour(colours.white)
- print(" : Change nothing")
- term.setTextColour(colours.green)
- write("settings")
- term.setTextColour(colours.white)
- print(" : Change passwords and side")
- term.setTextColour(colours.green)
- write("unistall")
- term.setTextColour(colours.white)
- print(" : Unistall doorlock")
- print(" ")
- term.setTextColour(colours.yellow)
- write("@doorlock>")
- choise = read()
- if choise ~= "exit" and choise ~= "unistall" and choise ~= "settings" then
- term.setTextColour(colours.red)
- print("unknown command")
- os.sleep(1.5)
- os.reboot()
- end
- if choise == "unistall" then
- fs.delete("/CB/doorlock")
- os.reboot()
- end
- if choise == "exit" then
- os.reboot()
- end
- if choise == "settings" then
- Settings()
- os.sleep(1)
- os.reboot()
- end
- end
- function Settings()
- term.setTextColour(colours.brown)
- write("Enter the user password : ")
- pass = read("*")
- write("Confirm : ")
- cpass = read("*")
- if pass ~= cpass then
- term.setTextColour(colours.red)
- print("Passwords are not corresponding !")
- os.sleep(1.5)
- os.reboot()
- end
- term.setTextColour(colours.brown)
- write("Enter the admin password : ")
- apass = read("*")
- write("Confirm : ")
- acpass = read("*")
- if apass ~= acpass then
- term.setTextColour(colours.red)
- print("Passwords are not corresponding !")
- os.sleep(1.5)
- os.reboot()
- end
- if apass == pass then
- term.setTextColour(colours.red)
- print("User and admin passwords are the same !")
- os.sleep(1.5)
- os.reboot()
- end
- term.setTextColour(colours.white)
- write("Side of the door : ")
- side = read()
- if side ~= "bottom" and side ~= "top" and side ~= "back" and side ~= "front" and side ~= "right" and side ~= "left" then
- term.setTextColour(colours.red)
- print("Side not exists.")
- os.sleep(1.5)
- os.reboot()
- end
- term.setTextColour(colours.green)
- wr = fs.open("/CB/doorlock", "w")
- wr.writeLine(pass)
- wr.writeLine(apass)
- wr.writeLine(side)
- wr.close()
- pas = fs.open("/CB/password", "w")
- pas.write("none")
- pas.close()
- print("Password sucessfuly set")
- os.sleep(2)
- end
- if not fs.exists("/CB/doorlock") then
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColour(colours.red)
- print("Do you realy want to use DoorLock ?")
- print("This will set DoorLock as startup")
- if yNt() == false then
- os.reboot()
- end
- Settings()
- end
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColour(colours.blue)
- print("DoorLock V. 1.1.1")
- print(" ")
- file = fs.open("/CB/doorlock", "r")
- word = file.readLine()
- aword = file.readLine()
- sid = file.readLine()
- file.close()
- term.setTextColour(colours.brown)
- write("Password : ")
- passwd = read ("*")
- if passwd ~= word then
- if passwd == aword then
- Menu()
- os.sleep(1)
- os.reboot()
- else
- term.setTextColour(colours.red)
- print("wrong password")
- os.sleep(1.5)
- os.reboot()
- end
- end
- redstone.setOutput(sid, true)
- os.sleep(3)
- redstone.setOutput(sid, false)
- os.reboot()
Add Comment
Please, Sign In to add comment