Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Advanced Key Card Lock with Override and Logs by Simsfreak63
- term.clear()
- redstoneoutputside = "top" -- change this to the side you the redstone signal to be sent to
- password = "offblast" -- change this to your password
- adminpassword = "afterban" -- change this to admin password. admin can override the lock and open the door, but only from inside
- location = "Front Door" -- change this to the location you want to appear in the log
- logger = 6 -- change this to the id of the computer keeping the log
- redstone.setOutput(redstoneoutputside,true)
- rednet.open("left") -- change this to the position of your modem
- local w,h = term.getSize()
- function lock()
- while true do
- term.clear()
- term.setCursorPos((w/2)-6, 2)
- print("Lock Engaged")
- while true do
- event, back = os.pullEvent("disk")
- if fs.exists("disk/password") == true then
- sFile = "disk/password"
- hRead = fs.open(sFile, "r")
- sPass = hRead.readLine()
- user = hRead.readLine()
- hRead.close()
- if sPass == password then
- redstone.setOutput(redstoneoutputside,false)
- rednet.send(logger,"log")
- rednet.send(logger,"User "..user.." entered ["..location.."] at "..textutils.formatTime(os.time(),false)..".",false)
- os.reboot()
- else
- sleep(3)
- os.reboot()
- end
- end
- end
- end
- end
- local sOverride = false
- local function passwordinput()
- while true do
- term.setCursorPos(w/2-15, h/2-1)
- print("Enter Passord to Override Lock")
- term.setCursorPos(w/2-3, h/2)
- local password = read("*")
- if password == adminpassword then
- term.clear()
- term.setCursorPos(2, h/2)
- print("Access Granted. Press Enter to override lock or")
- term.setCursorPos(w/2-10, h/2+1)
- print("Backspace to cancel.")
- keyboardinput()
- else
- term.clear()
- term.setCursorPos(w/2-15, h/2)
- print("Access Denied. Resetting Lock.")
- sleep(2)
- os.reboot()
- end
- end
- end
- function keyboardinput()
- while true do
- local sEvent, param = os.pullEvent()
- if sEvent == "key" then
- if param == 28 then
- if sOverride == false then
- redstone.setOutput(redstoneoutputside, false)
- term.clear()
- term.setCursorPos(4, h/2)
- print("Door open. Press Enter again to Reset Lock.")
- sOverride = true
- else
- os.reboot()
- end
- elseif param == 14 then
- os.reboot()
- end
- end
- end
- end
- parallel.waitForAll(lock,passwordinput)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement