Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Simple Door Lock
- -- Created by DannySMc
- -- Version 1.2
- -- Platform: Lua Virtual Machine
- -- Security Method
- oldEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- -- Check for API
- os.loadAPI("uapi")
- rednet.open("bottom")
- -- Installer for Configuration File
- if fs.exists(".uLockConf") == false then
- uapi.cs()
- print("Running Installer...")
- sleep(0.5)
- term.setCursorPos(1,3)
- term.write("Redstone output side: ")
- strSide = read()
- term.setCursorPos(1,5)
- term.write("Redstone pulse time: ")
- strPulse = tonumber(read())
- term.setCursorPos(1,7)
- term.write("Terminal Label: ")
- strName = read()
- term.setCursorPos(1,9)
- term.write("Password for unlock: ")
- strPassword = read("*")
- term.setCursorPos(1,11)
- print("What is the name this program is saved as?")
- term.setCursorPos(1,12)
- term.write("Program Name: ")
- strProgName = read()
- strPassword = uapi.checksum(strPassword, 1000)
- -- Create Configuration File
- uapi.saveConfig({['progName']=strProgName, ['terminalName']=strName, ['redSide']=strSide, ['redPulse']=strPulse, ['lockPassword']=strPassword}, ".uLockConf")
- -- Startup File
- term.setCursorPos(1,14)
- print("Do you wish to create a startup file?")
- term.setCursorPos(1,15)
- repeat
- term.write("YES/NO: ")
- startupAnswer = read()
- until ((startupAnswer == "YES") or (startupAnswer == "NO"))
- if startupAnswer == "YES" then
- startFile = fs.open("startup", "w")
- startFile.writeLine('os.loadAPI("uapi")')
- startFile.writeLine('config = uapi.loadConfig(".uLockConf")')
- startFile.writeLine("shell.run(config.progName)")
- startFile.close()
- print("Install Complete!")
- sleep(0.5)
- else
- print("Install Complete!")
- sleep(0.5)
- end
- print("Rebooting the terminal...")
- sleep(1)
- os.reboot()
- end
- -- Load Configuration File
- config = uapi.loadConfig(".uLockConf")
- -- Password Lock Program
- uapi.cs()
- uapi.drawBox(1, 51, 1, 5, " ", "white", "cyan")
- uapi.drawBox(2, 51, 2, 3, " ", "white", "cyan")
- uapi.drawBox(3, 51, 3, 1, " ", "white", "cyan")
- uapi.printC(config.terminalName, 3, false, "white", "cyan")
- uapi.drawBox(1, 51, 19, 1, " ", "white", "cyan")
- uapi.printC("Password Lock (Ver 1.2) -> Created By DannySMc", 19, false, "white", "cyan")
- uapi.resetCol()
- term.setCursorPos(1, 10)
- term.write("> Password: ")
- password = read("*")
- password = uapi.checksum(password, 1000)
- if password == config.lockPassword then
- term.setCursorPos(1,11)
- print("> Password Correct!")
- rednet.send(16, "OPEN")
- sleep(0.5)
- os.reboot()
- else
- term.setCursorPos(1,11)
- print("> Password Incorrect!")
- sleep(1.5)
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement