SHOW:
|
|
- or go back to the newest paste.
| 1 | local pullEvent = os.pullEvent | |
| 2 | os.pullEvent = os.pullEventRaw | |
| 3 | ||
| 4 | - | local pass, admin, root = "ineptmad", "madinept", "rootim" |
| 4 | + | function clear() |
| 5 | term.setCursorPos(1,1) | |
| 6 | - | textutils.slowPrint ("Loading...")
|
| 6 | + | term.clear() |
| 7 | - | textutils.slowPrint ("Done Loading!")
|
| 7 | + | end |
| 8 | - | sleep(1) |
| 8 | + | |
| 9 | - | term.clear() |
| 9 | + | clear() |
| 10 | - | term.setCursorPos(1,1) |
| 10 | + | |
| 11 | ||
| 12 | - | textutils.slowPrint ("Welcome to SecurityDoorWatch")
|
| 12 | + | local setpass --for setting the password |
| 13 | - | textutils.slowPrint ("v0.5")
|
| 13 | + | local adminpass -- for setting the admin password |
| 14 | - | sleep(0.5) |
| 14 | + | local opentime -- for setting how long the door will stay open |
| 15 | - | term.clear() |
| 15 | + | local rootpass -- for setting the rootpass |
| 16 | local redstoneOutputSide | |
| 17 | - | print ("Door Lock v0.5")
|
| 17 | + | local args = {...}
|
| 18 | - | print ("Coded by Madster")
|
| 18 | + | |
| 19 | - | write "Passcode: " |
| 19 | + | if fs.exists("doorlock-settings") and args[1] ~= "reset" then
|
| 20 | - | input = read("*")
|
| 20 | + | local f = fs.open("doorlock-settings", "r")
|
| 21 | - | if input == pass then |
| 21 | + | setpass = f.readLine() |
| 22 | - | print ("Access Granted for 5 Seconds, better hurry!")
|
| 22 | + | adminpass = f.readLine() |
| 23 | - | redstone.setOutput ("left", true )
|
| 23 | + | rootpass = f.readLine() |
| 24 | - | sleep(5) |
| 24 | + | opentime = tonumber(f.readLine()) |
| 25 | - | os.shutdown() |
| 25 | + | redstoneOutputSide = f.readLine() |
| 26 | - | elseif input == admin then |
| 26 | + | f.close() |
| 27 | - | print ("Door will remain open, remember to close!")
|
| 27 | + | |
| 28 | - | redstone.setOutput ("left", true )
|
| 28 | + | print("Please define the password to gain access to the door:")
|
| 29 | - | write "Passcode: " |
| 29 | + | setpass = read("*")
|
| 30 | - | input2 = read("*")
|
| 30 | + | clear() |
| 31 | - | if input2 == admin then |
| 31 | + | |
| 32 | - | redstone.setOutput ("left", false )
|
| 32 | + | print("Please define the password to gain root access to the computer(to edit files):")
|
| 33 | - | os.shutdown() |
| 33 | + | rootpass = read("*")
|
| 34 | - | else |
| 34 | + | clear() |
| 35 | - | textutils.slowPrint ("Incorrect Admin passcode, force-closing door!")
|
| 35 | + | |
| 36 | - | sleep( 3 ) |
| 36 | + | print("Please define the admin password. This password will keep the door open when entered")
|
| 37 | - | os.shutdown() |
| 37 | + | adminpass = read("*")
|
| 38 | - | end |
| 38 | + | clear() |
| 39 | - | elseif input == root then |
| 39 | + | |
| 40 | - | textutils.slowPrint ("Welcome, you may now edit the programs/files on this computer!")
|
| 40 | + | print("Please define the amount of time the redstone pulse will be on:")
|
| 41 | - | term.clear() |
| 41 | + | opentime = tonumber(read()) |
| 42 | - | os.pullEvent = pullEvent |
| 42 | + | clear() |
| 43 | - | print ("Root permissions enabled")
|
| 43 | + | |
| 44 | - | return |
| 44 | + | local vside = false |
| 45 | while true do | |
| 46 | - | print ("Uhhm... Wrong password..")
|
| 46 | + | print("Which side is the door on?")
|
| 47 | - | sleep(2) |
| 47 | + | redstoneOutputSide = read() |
| 48 | - | os.shutdown() |
| 48 | + | for k,v in pairs(rs.getSides()) do |
| 49 | if v == redstoneOutputSide then | |
| 50 | vside = true | |
| 51 | break | |
| 52 | end | |
| 53 | end | |
| 54 | if vside then break end | |
| 55 | print("Invalid side!")
| |
| 56 | sleep(0.5) | |
| 57 | clear() | |
| 58 | end | |
| 59 | local f = fs.open("doorlock-settings", "w")
| |
| 60 | f.writeLine(setpass) | |
| 61 | f.writeLine(adminpass) | |
| 62 | f.writeLine(rootpass) | |
| 63 | f.writeLine(tostring(opentime)) | |
| 64 | f.writeLine(redstoneOutputSide) | |
| 65 | f.close() | |
| 66 | end | |
| 67 | ||
| 68 | while true do | |
| 69 | clear() | |
| 70 | print ("Loading...")
| |
| 71 | print ("Done Loading!")
| |
| 72 | sleep(1) | |
| 73 | term.clear() | |
| 74 | term.setCursorPos(1,1) | |
| 75 | ||
| 76 | print ("Door Lock v0.5")
| |
| 77 | print ("Coded by Madster")
| |
| 78 | write "Passcode: " | |
| 79 | input = read("*")
| |
| 80 | if input == setpass then | |
| 81 | print ("Access Granted for " .. tostring(opentime) .. " seconds, better hurry!")
| |
| 82 | rs.setOutput(redstoneOutputSide, true) | |
| 83 | sleep(opentime) | |
| 84 | rs.setOutput(redstoneOutputSide, false) | |
| 85 | os.shutdown() | |
| 86 | elseif input == adminpass then | |
| 87 | print ("Door will remain open, remember to close!")
| |
| 88 | rs.setOutput(redstoneOutputSide, true) | |
| 89 | while true do | |
| 90 | term.clear() | |
| 91 | write "Passcode: " | |
| 92 | input2 = read("*")
| |
| 93 | if input2 == adminpass then | |
| 94 | rs.setOutput(redstoneOutputSide, false) | |
| 95 | os.shutdown() | |
| 96 | break | |
| 97 | end | |
| 98 | end | |
| 99 | elseif input == rootpass then | |
| 100 | textutils.slowPrint ("Welcome, you may now edit the programs/files on this computer!")
| |
| 101 | term.clear() | |
| 102 | os.pullEvent = pullEvent | |
| 103 | print ("Root permissions enabled")
| |
| 104 | return | |
| 105 | else | |
| 106 | print ("Uhhm... Wrong password..")
| |
| 107 | sleep(2) | |
| 108 | os.shutdown() | |
| 109 | end | |
| 110 | end |