Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --simple door lock
- --pastebin get NV4DJYdf startup
- --change the values under the comment "change these values"
- --name this program startup, then restart the computer
- --inspired/copied by/from
- --http://computercraft.info/wiki/Making_a_Password_Protected_Door
- --"change these values"
- local side = "default1"
- local password = "password1"
- local openTime = 5
- local adminPassword="admin1"
- local adminTime= 10
- --make copy of os.pullevent
- local pullEventCopy = os.pullEvent
- --make it so that the program can't be terminated by
- -- holding ctrl-t
- os.pullEvent = os.pullEventRaw
- --check that adminPassword and password aren't the same
- --and aren't the default values
- local hasErrors=false
- if(adminPassword==password) then
- print("Unresolved: The adminPassword can't be the same as the password")
- hasErrors=true
- end
- if(adminPassword=="admin") then
- print("Unresolved: The adminPassword has to be changed")
- hasErrors=true
- end
- if(password=="password") then
- print("Unresolved: The password has to be changed")
- hasErrors=true
- end
- if(side=="default") then
- print("Unresolved: The side hasn't been configured")
- hasErrors=true
- end
- if hasErrors then
- print("edit the file to change these values.")
- error("Exited")
- end
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- print("Password:")
- input = read("*")
- if input == password then --password
- print("Correct!")
- redstone.setOutput(side, true)
- sleep(openTime)
- redstone.setOutput(side, false)
- elseif input==adminPassword then --admin
- os.pullEvent = pullEventCopy--enable ctrl-t
- print("Hold ctrl-t to enter admin mode.")
- sleep(adminTime)
- os.pullEvent = os.pullEventRaw--disable ctrl-t
- else --fail
- print("Incorrect!")
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement