This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Macapple's profile picture

Check for Keycard, and if it's not there, ask a password

Started by Macapple, 21 May 2016 - 12:00 PM
Macapple #1
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]

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?
Macapple #2
Posted 21 May 2016 - 02:10 PM
Solved, a guy in the server helped.

Can rm thistopic
Lyqyd #3
Posted 22 May 2016 - 12:20 AM
Please post the solution you found, for anyone experiencing similar issues in the future.