Advertisement
Birog

Pflanzenfarm

Mar 12th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.56 KB | None | 0 0
  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. --local pass, admin, root = "ineptmad", "madinept", "rootim"
  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("                                                   ")
  72.     print("              Willkommen in Minewood               ")
  73.     print("      Pflanzenfarm by Drealchen and MwieMicha      ")
  74.     print("      Zugriff auf dieses System nicht erlaubt      ")
  75.     print()
  76.     term.setCursorPos(1,7)
  77.     write("Passcode: ")
  78.     input = read("*")
  79.     if input == setpass then
  80.         print ("Access Granted")
  81.                 sleep(2)
  82.                 clear()
  83.         print(" ************************************************* ")
  84.         print(" *                                               * ")
  85.         print(" * [1] Strom einschalten/ ausschalten            * ")
  86.         print(" *                                               * ")
  87.         print(" * [3] Tuer zum Dunkel Bereich oeffnen           * ")
  88.         print(" *                                               * ")
  89.         print(" ************************************************* ")
  90.         print()
  91.         write("   Auswahl : ")
  92.         auswahl = io.read()
  93.         if auswahl == "3" then
  94.          redstone.setBundledOutput("bottom",colors.blue)
  95.                  sleep(1)
  96.          redstone.setBundledOutput("bottom",0)
  97.          sleep(5)
  98.          redstone.setBundledOutput("bottom",colors.blue)
  99.                  sleep(1)
  100.          redstone.setBundledOutput("bottom",0)
  101.         elseif auswahl == "1" then
  102.          redstone.setBundledOutput("bottom",colors.orange)
  103.                  sleep(1)
  104.          redstone.setBundledOutput("bottom",0)
  105.         else
  106.          return false
  107.         end
  108.         os.reboot()
  109.     elseif input == adminpass then
  110.         print ("Willkommen Admin")
  111.         while true do
  112.             term.clear()
  113.             return
  114.         end
  115.     elseif input == rootpass then
  116.         textutils.slowPrint ("Welcome, you may now edit the programs/files on this computer!")
  117.         term.clear()
  118.         os.pullEvent = pullEvent
  119.         print ("Root permissions enabled")
  120.         return
  121.     else
  122.         print ("Uhhm... Wrong password..")
  123.         sleep(2)
  124.         os.shutdown()
  125.     end
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement