Theshadow989

Test File 3 (free)

Dec 21st, 2016
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.04 KB | None | 0 0
  1. local _seclevel = 3
  2. local sides = {"top", "bottom", "left", "right", "front", "back"}
  3. local _monitor, _drive= "", ""
  4. local mon = peripheral.wrap("monitor_0")
  5. local _passwords = {"5BCE0FE268FA6B4B801FB1082F185B90000AB1258202C653F64B4F037D172336", "9EA9B8889DE45FA608597CB52B79749E2E32C97EF6481CFE6B315655933331F8", "387B8E8247FE18FFFA39FA2DFCDFB555633A0585B6F7D781FFCDA8E82AA20232", "51B92A735030BDBF16100656E55D9F98D0CACA269266782E2F3E850894898BEE", "7B48A89633F05F625E007F3287CD3858584503B9972578791D321851C9D44E51"}
  6.  
  7. for i=1, #sides do
  8.     if peripheral.isPresent(sides[i]) then
  9.         if peripheral.getType(sides[i]) == "monitor" then
  10.             _monitor = sides[i]
  11.         end
  12.         if peripheral.getType(sides[i]) == "drive" then
  13.             _drive = sides[i]
  14.         end
  15.     end
  16. end
  17.  
  18. term.clear()
  19. term.setCursorPos(1,1)
  20.  
  21. mon.clear()
  22. mon.setBackgroundColor(colors.black)
  23. mon.setTextColor(colors.white)
  24. mon.setCursorPos(2,3)
  25. mon.write("Ready")
  26.  
  27. while true do
  28.     event, side = os.pullEvent()
  29.  
  30.     if event == "disk" then
  31.         local time = os.time()
  32.         local formattedTime = textutils.formatTime(time, false)
  33.         local data
  34.         local check = "blank"
  35.         local passwordMatch = -1
  36.         if fs.exists("disk/password") then            
  37.             local file = fs.open("disk/password","r")  
  38.             data = file.readLine()                  
  39.             file.close()
  40.             for i=1, #_passwords do
  41.                 if data == _passwords[i] then
  42.                     passwordMatch = i
  43.                 end
  44.             end
  45.  
  46.             if passwordMatch == -1 then
  47.                 mon.setBackgroundColor(colors.red)
  48.                 mon.setTextColor(colors.black)
  49.                 mon.clear()
  50.                 mon.setCursorPos(1,2)
  51.                 mon.write("Access")
  52.                 mon.setCursorPos(1,4)
  53.                 mon.write("Denied")
  54.  
  55.                 print("- Invalid Password. TIME:" .. formattedTime)
  56.  
  57.                 -- PASSWORD INVALID (DO STUFF HERE)
  58.                
  59.             elseif passwordMatch < _seclevel then
  60.                 mon.setBackgroundColor(colors.red)
  61.                 mon.setTextColor(colors.black)
  62.                 mon.clear()
  63.                 mon.setCursorPos(1,2)
  64.                 mon.write("Higher")
  65.                 mon.setCursorPos(1,3)
  66.                 mon.write("Access")
  67.                 mon.setCursorPos(1,4)
  68.                 mon.write("Required")
  69.  
  70.                 print("- Low Access. TIME:" .. formattedTime)
  71.  
  72.                 -- NEED HIGHER ACCESS CARD (DO STUFF HERE)
  73.  
  74.             elseif passwordMatch >= _seclevel then
  75.                 mon.setBackgroundColor(colors.green)
  76.                 mon.setTextColor(colors.black)
  77.                 mon.clear()
  78.                 mon.setCursorPos(1,2)
  79.                 mon.write("Access")
  80.                 mon.setCursorPos(1,4)
  81.                 mon.write("Granted")
  82.  
  83.                 print("- Access granted. Level " .. passwordMatch .. " card. TIME:" .. formattedTime)
  84.  
  85.                 -- ACCESS GRANTED (DO STUFF HERE)
  86.  
  87.             end
  88.         else
  89.             mon.setBackgroundColor(colors.red)
  90.             mon.setTextColor(colors.black)
  91.             mon.clear()
  92.             mon.setCursorPos(1,2)
  93.             mon.write("Invalid")
  94.             mon.setCursorPos(1,3)
  95.             mon.write("Access")
  96.             mon.setCursorPos(1,4)
  97.             mon.write("Card")
  98.  
  99.             print("- Unformatted Card. TIME:" .. formattedTime)
  100.  
  101.             -- INVALID ACCESS CARD (DO STUFF HERE)
  102.         end
  103.  
  104.         peripheral.call(_drive, "ejectDisk")
  105.  
  106.         os.sleep(4)
  107.     end
  108.  
  109.     mon.setBackgroundColor(colors.black)
  110.     mon.setTextColor(colors.white)
  111.     mon.clear()
  112.     mon.setCursorPos(2,3)
  113.     mon.write("Ready")
  114.  
  115. end
Add Comment
Please, Sign In to add comment