Advertisement
MrSnake20_15

Security

Jun 16th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. local com = require('component')
  2. local gpu = com.gpu
  3. local term = require('term')
  4. local computer = require('computer')
  5.  
  6. --Переменные:
  7.  
  8. --Пароль
  9. local pass = '1234'
  10. --Максимальное кол-во попыток
  11. local max = 1
  12. --Текущий номер попытки
  13. local pop = 1
  14. --Что говорить, если пароль введен верно
  15. local str = {'CHECKING PASSWORD................................','UNLOCKING....WAIT.............................................................'}
  16.  
  17.  
  18. --Ставьте в функциях что-то,нужное вам
  19. --Если успешно введен пароль
  20. function ok()
  21.   gpu.setForeground(0x006400)
  22.   print('UNLOCK DONE!!')
  23. end
  24. --Если неуспешно введен пароль
  25. function no()
  26.  
  27. end
  28.  
  29. --Не трогать
  30. function unlock(str)
  31.     for i = 1, #str do
  32.         io.write(str:sub(i,i)) os.sleep(0.1)
  33.     end
  34. end
  35.  
  36. function info()
  37. term.clear()
  38. gpu.setForeground(0xFFFF00)
  39. print([[
  40. +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  41.                   [SNAKE SEC]
  42. +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  43.                   [CONTROL]
  44. +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  45. ]])
  46. gpu.setForeground(0xFFFFFF)
  47. end
  48.  
  49. while true do
  50.   info()
  51.   gpu.setForeground(0xFF0000)
  52.   print('Попыток: [' .. pop .. '/' .. max .. ']')
  53.   print('Введите код разблокировки:')
  54.   io.write('>>')
  55.   local v,s = pcall(io.read)
  56.   if s == pass then
  57.   for i = 1, #str do
  58.   gpu.setForeground(0xFFFFFF)
  59.   print(unlock(str[i]))
  60.   end
  61.   ok()
  62.   gpu.setForeground(0xFFFFFF)
  63.   break
  64.   else
  65.     no()
  66.     print('WRONG PASSWORD!!!')
  67.     computer.beep(1900,0.1)
  68.     if pop < max then
  69.       print('Try again!')
  70.       os.sleep(1)
  71.       pop = pop + 1
  72.     else
  73.       print('HASTA LA VISTA!')
  74.       os.sleep(0.5)
  75.       computer.shutdown(true)
  76.     end
  77.   end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement