Posted 21 May 2016 - 02:00 PM
Hi everyone! I'm trying to make a security lock, but I can't get it to work as I intend to.
My code is [PASTEBIN LINK]
Is there something wrong in the code?
My code is [PASTEBIN LINK]
local pass = "Temp"
local dPas = "Debug"
local timer = 5
local delay = 1
local side = "left"
local dside = "bottom"
--//This code runs first on computer startup, checking for a valid keycard in the bottom disk
while true do
if disk.isPresent(dside) then
if fs.exists("disk/security/key") then
shell.run("disk/security/key")
if key == "Code" then
disk.eject(dside)
rs.setOutput(side,false)
sleep(timer)
rs.setOutput(side,true)
else
disk.eject(dside)
end
else
disk.eject(dside)
end
end
else
--// This code must run only if user has turned on the computer without a keycard in the bottom disk driver, or if the keycard is invalid
print("Door is Locked")
sleep(delay)
print("Insert Password: ")
sleep(delay)
local input = read("x")
if input == pass then --If the password is correct do
rs.setOutput(side,false)
sleep(timer)
rs.setOutput(side,true)
sleep(delay)
os.shutdown()
else --If the password is incorrect do
print ("Incorrect password)
sleep(delay)
os.shutdown()
end
end
end
Is there something wrong in the code?