Jump to content




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

computer lua

2 replies to this topic

#1 Macapple

  • Members
  • 28 posts

Posted 21 May 2016 - 01: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?

#2 Macapple

  • Members
  • 28 posts

Posted 21 May 2016 - 01:10 PM

Solved, a guy in the server helped.

Can rm thistopic

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 21 May 2016 - 11:20 PM

Please post the solution you found, for anyone experiencing similar issues in the future.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users