Advertisement
Guest User

startup

a guest
Jun 7th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local function center()
  2.   term.setCursorPos(26,10)
  3.  
  4. end
  5.  
  6. os.pullEvent = os.pullEventRaw
  7.  
  8. term.clear()
  9. term.setCursorPos(1,1)
  10.  
  11. local tries = 3
  12. local correct = 0
  13. while tries > 0 and correct == 0 do
  14.     term.clear()
  15.     term.setCursorPos(1, 1)
  16.     print('You have '..tries..' tries to login!')
  17.     print('Username: ')
  18.     term.setCursorPos(11, 2)
  19.     local Username = read()
  20.     print('Password: ')
  21.     term.setCursorPos(11, 3)
  22.     local password = read('*')
  23.     local doesExist = 0
  24.     if fs.exists('/.Users/.'..Username) == true then
  25.         local userFile = fs.open('/.Users/.'..Username, 'r')
  26.         local correctPass = userFile.readAll()
  27.         doesExist = 1
  28.        
  29.     else
  30.         doesExist = 0
  31.        
  32.     end
  33.     if password == correctPass and doesExist == 1 then
  34.         shell.run('/.aOS/Menu')
  35.         correct = 1
  36.        
  37.     else
  38.         tries = tries - 1
  39.         if doesExist == 1 then
  40.             userFile.close()
  41.            
  42.         end
  43.        
  44.     end
  45.    
  46. end
  47. if tries == 0 then
  48.     term.clear()
  49.     term.setCursorPos(1, 1)
  50.     print('You ran out of tries to login!')
  51.     sleep(2)
  52.     os.reboot()
  53.    
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement