Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local pullEvent = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. function clear()
  5.  term.setCursorPos(1,1)
  6.  term.clear()
  7. end
  8.  
  9. clear()
  10.  
  11.  
  12. local setpass --for setting the password
  13. local adminpass -- for setting the admin password
  14. local opentime -- for setting how long the door will stay open
  15. local rootpass -- for setting the rootpass
  16. local redstoneOutputSide
  17. local args = {...}
  18.  
  19. if fs.exists("doorlock-settings") and args[1] ~= "reset" then
  20.     local f = fs.open("doorlock-settings", "r")
  21.     setpass = f.readLine()
  22.     adminpass = f.readLine()
  23.     rootpass = f.readLine()
  24.     opentime = tonumber(f.readLine())
  25.     redstoneOutputSide = f.readLine()
  26.     f.close()
  27. else
  28.     print("Please define the password to gain access to the door:")
  29.     setpass = read("*")
  30.     clear()
  31.    
  32.     print("Please define the password to gain root access to the computer(to edit files):")
  33.     rootpass = read("*")
  34.     clear()
  35.    
  36.     print("Please define the admin password. This password will keep the door open when entered")
  37.     adminpass = read("*")
  38.     clear()
  39.  
  40.     print("Please define the amount of time the redstone pulse will be on:")
  41.     opentime = tonumber(read())
  42.     clear()
  43.    
  44.     local vside = false
  45.     while true do
  46.         print("Which side is the door on?")
  47.         redstoneOutputSide = read()
  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 Joeman05")
  78.     write "Passcode: "
  79.     input = read("*")
  80.     if input == setpass then
  81.         print ("Access Granted")
  82.             rs.setBundledOutput(redstoneOutputSide, colors.magenta)
  83.             sleep(1)
  84.             rs.setBundledOutput(redstoneOutputSide, colors.magenta)
  85.             sleep(1)
  86.             rs.setBundledOutput(redstoneOutputSide, colors.magenta)
  87.             sleep(1)
  88.             rs.setBundledOutput(redstoneOutputSide, colors.magenta)
  89.             sleep(1)
  90.             rs.setBundledOutput(redstoneOutputSide, colors.magenta)
  91.             sleep(1)
  92.             rs.setBundledOutput(redstoneOutputSide, colors.magenta)
  93.         sleep(opentime)
  94.             rs.setBundledOutput(redstoneOutputSide, colors.orange)
  95.             sleep(1)
  96.             rs.setBundledOutput(redstoneOutputSide, colors.orange)
  97.             sleep(1)
  98.             rs.setBundledOutput(redstoneOutputSide, colors.orange)
  99.             sleep(1)
  100.             rs.setBundledOutput(redstoneOutputSide, colors.orange)
  101.             sleep(1)
  102.             rs.setBundledOutput(redstoneOutputSide, colors.orange)
  103.             sleep(1)
  104.             rs.setBundledOutput(redstoneOutputSide, colors.orange)
  105.             sleep(1)
  106.         rs.setBundledOutput(redstoneOutputSide, 0)
  107.         os.shutdown()
  108.     elseif input == adminpass then
  109.         print ("Door will remain open, remember to close!")
  110.         rs.setOutput(redstoneOutputSide, true)
  111.         while true do
  112.             term.clear()
  113.                 write "Passcode: "
  114.                 input2 = read("*")
  115.             if input2 == adminpass then
  116.                 rs.setOutput(redstoneOutputSide, false)
  117.                 os.shutdown()
  118.             break
  119.             end
  120.         end
  121.     elseif input == rootpass then
  122.         textutils.slowPrint ("Welcome, you may now edit the programs/files on this computer!")
  123.         term.clear()
  124.         os.pullEvent = pullEvent
  125.         print ("Root permissions enabled")
  126.         return
  127.     else
  128.         print ("Uhhm... Wrong password..")
  129.         sleep(2)
  130.         os.shutdown()
  131.     end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement