Advertisement
Guest User

Untitled

a guest
Jan 20th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. --APIs
  2. os.pullEvent = os.pullEventRaw
  3. os.loadAPI("/DZSystem/API/Color")
  4.  
  5. --Variables
  6. local quit, user, registered = false
  7. local name, pass, passCnfrm = nil
  8. local usersDir = "/DZSystem/users/"
  9. local regStr = "Registration"
  10. local authStr = "Authorization"
  11. local program = "V 1.0"
  12.  
  13. --Functions
  14. local function clr(color,str)
  15. term.setBackgroundColor(color)
  16. term.setCursorPos(1,1)
  17. term.clear()
  18. print(str)
  19. for i=1,50 do
  20. if i == 50 then
  21. print("-")
  22. else
  23. write("-")
  24. end
  25. end
  26. end
  27.  
  28. repeat
  29. clr(Color.Lime,program)
  30. print("Do you have account?")
  31. print("Y\N")
  32. local event, key = os.pullEvent()
  33. until (key == keys.y) or (key == keys.n)
  34. if key == keys.y then
  35. --Begin Registration
  36. repeat --begin
  37. clr(Color.Lime,regStr)
  38. write("Enter your name: ")
  39. name = read()
  40. user = fs.exists(usersDir..name)
  41. if user == true then
  42. clr(Color.Lime,regStr)
  43. print("User already registered!")
  44. print("Try another name.")
  45. sleep(1)
  46. else
  47. quit = true
  48. end
  49. until quit == true --end
  50. quit = false
  51. print("Ok!")
  52. sleep(1)
  53. quit = true
  54. repeat --begin
  55. clr(Color.Lime,regStr)
  56. write("Enter your password: ")
  57. pass = read("*")
  58. write("Confirm your password: ")
  59. passCnfrm = read("*")
  60. if pass == passCnfrm then
  61. print("Ok!")
  62. sleep(1)
  63. quit = true
  64. else
  65. quit = false
  66. clr(Color.Lime,regStr)
  67. print("Incorrect password!")
  68. sleep(1)
  69. end
  70. until quit == true --end
  71. file = fs.open(usersDir..name,"a")
  72. --file.writeLine(name)
  73. file.writeLine(pass)
  74. file.close()
  75. sleep(2)
  76. --End Registration
  77. else
  78. --Begin Authorization
  79. quit = false
  80.  
  81. repeat --begin
  82. clr(Color.Lime,authStr)
  83. write("Enter your name: ")
  84. name = read()
  85. user = fs.exists(usersDir..name)
  86. if user == true then
  87. print("Ok!")
  88. file = fs.open(usersDir..name,"r")
  89. passCnfrm = file.readLine()
  90. file.close()
  91. sleep(1)
  92. quit = true
  93. else
  94. clr(Color.Lime,authStr)
  95. print("User is not exists! Try again.")
  96. sleep(1)
  97. end
  98. until quit == true --end
  99. quit = false
  100. repeat
  101. clr(Color.Lime,authStr)
  102. write("Enter your password: ")
  103. pass = read()
  104. if pass == passCnfrm then
  105. print("Ok!")
  106. sleep(3)
  107. quit = true
  108. else
  109. clr(Color.Lime,authStr)
  110. print("Incorrect password!")
  111. sleep(1)
  112. end
  113. until quit == true
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement