Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
70
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 ("MM MANSIONS")
  77.     print ("Secured by VEBAsecurity")
  78.     write "Enter Passcode: "
  79.     input = read("*")
  80.     if input == setpass then
  81.         print ("ACCESS GRANTED FOR " .. tostring(opentime) .. " SECONDS!")
  82.         rs.setOutput(redstoneOutputSide, true)
  83.         sleep(opentime)
  84.         rs.setOutput(redstoneOutputSide, false)
  85.         os.shutdown()
  86.     elseif input == adminpass then
  87.         print ("ACCESS GRANTED - DOOR WILL REMAIN OPEN")
  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 ("ACCESS DENIED")
  107.         sleep(2)
  108.         os.shutdown()
  109.     end
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement