Posted 13 December 2012 - 01:24 AM
as we all know what this script is going to do lets make it more awesome then the previous 100 locks (advlock is the exception, as he has animations! :)/> ).
to start off this is designed to be a almost idiot proof lock(ie you cant screw the setting up of it unless you try really hard ;)/> ).
this lock has a built in config, with options for it to both be a door lock/redstone lock or a terminal lock without editing it at all :D/> .
this is designed for server use and includes a user and admin password for doors so you can edit the computer without needing to place a disk drive to disable the lock and user for general users to unlock door.
code is below.
changelog
added * to password entry
build 04
fixed config loader not loading door side even though it is configuable
any suggestions on how to make is any better would be nice(except animations because im not that good at lua)
to start off this is designed to be a almost idiot proof lock(ie you cant screw the setting up of it unless you try really hard ;)/> ).
this lock has a built in config, with options for it to both be a door lock/redstone lock or a terminal lock without editing it at all :D/> .
this is designed for server use and includes a user and admin password for doors so you can edit the computer without needing to place a disk drive to disable the lock and user for general users to unlock door.
code is below.
Spoiler
local oldevntpull =os.pullEvent
os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)
local bCopy = true
textutils.slowPrint("Elcid Locks Inc xterm lock ver 1.4.5 build 04\nrunning in "..os.version())
if fs.exists("pswcfg") then
hRead = fs.open("pswcfg","r")
sIsDoorLock = hRead.readLine()
sAdmin = hRead.readLine()
sUser = hRead.readLine()
sSide = hRead.readLine()
hRead.close()
if sIsDoorLock == "door" then
print("Login Required:")
sInput = read("*")
if sAdmin == sInput then
print("Successful Login!")
print("unlocking terminal into debug mode")
sleep(1)
elseif sUser == sInput then
print("Successful Login!")
print("unlocking door")
redstone.setOutput(sSide,true)
sleep(3)
redstone.setOutput(sSide,false)
os.shutdown()
else
print("Bad Login. Shutting Down Computer")
sleep(2)
os.shutdown()
end
elseif sIsDoorLock == "nondoor" then
print("Login Required:")
sInput = read()
if sAdmin == sInput then
print("Successful Login!")
print("unlocking terminal into debug mode")
sleep(1)
else
print("Bad Login. Shutting Down Computer")
sleep(1)
os.shutdown()
end
end
else
print("config for lock not found ,Assuming new computer")
sleep(1)
print("is this a door lock computer?")
sInput = read()
if sInput == "yes" then
print("what side is the door on?(left,right,back,front)")
sDoorside = read()
print("please enter admin password to acess terminal")
sAdmin = read()
print("please enter the user password to open the door")
sUser = read()
hWrite = fs.open("pswcfg","w")
hWrite.write("door\n"..sAdmin.."\n"..sUser.."\n"..sDoorside)
hWrite.close()
else
print("please enter the admin password to acess terminal")
sAdmin = read()
hWrite = fs.open("pswcfg","w")
hWrite.write("nondoor\n"..sAdmin)
hWrite.close()
end
print("data saved to file pswcfg, start this program on startup?")
sInput = read()
if sInput == "yes" then
print("ready to copy in lock code to startup")
if fs.exists("startup") then
print("error: file exists,delete?")
sInput = read()
if sInput =="yes" then
fs.delete("startup")
end
end
elseif sInput =="no" then
bCopy = false
end
if bCopy == true then
fs.copy(shell.getRunningProgram(),"startup")
else
print("not coping")
end
print("configuation of new lock complete, ready for use")
end
os.pullEvent = oldevntpull
Spoiler
build 05added * to password entry
build 04
fixed config loader not loading door side even though it is configuable
any suggestions on how to make is any better would be nice(except animations because im not that good at lua)
Edited on 23 April 2014 - 05:44 AM