Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local code
- local counter
- local userInput = ""
- local userBkp = ""
- local save = function(data, name)
- if not fs.exists('/data') then
- fs.makeDir('/data')
- end
- local file = fs.open('/data/'..name, 'w')
- file.write(textutils.serialize(data))
- file.close()
- end
- local load = function(name)
- if fs.exists('/data/'..name) then
- local file = fs.open('/data/'..name, 'r')
- data = textutils.unserialize(file.readAll())
- file.close()
- end
- return data
- end
- if not fs.exists('/data/door') then
- print("Enter New Door Code Below: ")
- code = read()
- save(code,"door")
- shell.run("pastebin run AUgEmXrk")
- else
- code = load('door')
- end
- if not fs.exists('/data/door') then
- print("Enter New Door Code Below: ")
- code = read()
- save(code,"door")
- else
- code = load('door')
- end
- if not fs.exists('/data/tries') then
- print("Enter New Door Code Below: ")
- counter = 0
- save(counter,"tries")
- else
- counter = load('tries')
- end
- while true do
- if counter >= 3 then
- term.setCursorPos(1, 1)
- term.clear()
- print("Door Protected by BandyB7 Lock V2.0")
- print("ATTEMPTED ENTRY DETECTED")
- while true do
- local event, char = os.pullEvent("char")
- if event == "terminate" then
- term.clear()
- term.setCursorPos(1, 1)
- print("Terminating...")
- os.sleep(1)
- term.clear()
- term.setCursorPos(1, 1)
- os.sleep(2)
- print("Just Kidding.")
- print("Door STILL Protected by BandyB7 Lock V2.0")
- print("ATTEMPTED ENTRY DETECTED")
- userBkp = ""
- end
- if char ~= nil then
- userBkp = userBkp .. char
- if #userBkp == 19 then
- break
- end
- end
- end
- if userBkp == load("bkp") then
- save(0, "tries")
- os.reboot()
- end
- userBkp = ""
- else
- term.setCursorPos(1, 1)
- term.clear()
- print("Door Protected by BandyB7 Lock V2.0")
- print("Enter Code Below: ")
- while true do
- local event, char = os.pullEvent("char")
- if event == "terminate" then
- term.clear()
- term.setCursorPos(1, 1)
- print("Terminating...")
- os.sleep(1)
- term.clear()
- term.setCursorPos(1, 1)
- os.sleep(2)
- print("Just Kidding.")
- print("Door STILL Protected by BandyB7 Lock V2.0")
- print("Enter Code Below: ")
- end
- if char ~= nil then
- userInput = userInput .. char
- term.write("*")
- if #userInput == #code then
- break
- end
- end
- end
- if userInput == code then
- print("\nWelcome")
- save(0, "tries")
- redstone.setOutput("bottom", true)
- sleep(3)
- redstone.setOutput("bottom", false)
- else
- print("\nIncorrect Password")
- sleep(1)
- counter = counter + 1
- save(counter, "tries")
- end
- userInput = ""
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment