Legebatterie

maxintosh2--login

Dec 21st, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. term.clear()
  2.  
  3.  
  4. paintutils.drawFilledBox(1,1,51,51,colors.blue)
  5. paintutils.drawFilledBox(13,5,39,14,colors.black)
  6.  
  7. finnishedWaiting=false
  8. login=false
  9. correctInput=false
  10. verified=false
  11.  
  12. hidden="*"
  13. newHidden=nil
  14.  
  15. term.setTextColor(colors.white)
  16. term.setCursorPos(16,7)
  17. write("Username:")
  18. term.setCursorPos(16,9)
  19. write("Password:")
  20. term.setCursorPos(24,11)
  21. term.setTextColor(colors.green)
  22. write("LOGIN")
  23. term.setCursorPos(32,13)
  24. term.setTextColor(colors.gray)
  25. write("Sign In")
  26. term.setCursorPos(35,6)
  27. term.setTextColor(colors.red)
  28. write("hide")
  29. term.setCursorPos(16,12)
  30. write("reboot")
  31. term.setTextColor(colors.white)
  32. term.setCursorPos(13,5)
  33. write("###########################")
  34. term.setCursorPos(13,14)
  35. write("###########################")
  36.  
  37. for i=6,13 do
  38. term.setCursorPos(13,i)
  39. write("#")
  40. end
  41.  
  42. for i=6,13 do
  43. term.setCursorPos(39,i)
  44. write("#")
  45. end
  46. --DESIGN
  47.  
  48.  
  49.  
  50. --Login-Screen
  51. while login==false do
  52. event,numb,x,y=os.pullEvent("mouse_click")
  53. term.setCursorPos(x,y)
  54.  
  55. if y==7 then
  56. paintutils.drawFilledBox(26,7,38,7,colors.black)
  57. term.setCursorPos(26,7)
  58. name=read()
  59.  
  60. elseif y==12 then
  61. os.reboot()
  62.  
  63. elseif y==9 then
  64. paintutils.drawFilledBox(26,9,38,9,colors.black)
  65. term.setCursorPos(26,9)
  66. pass=read(hidden)
  67.  
  68. elseif y==11 then
  69. login=true
  70.  
  71. elseif y==6 then
  72. hidden=newHidden
  73. if hidden=="*" then
  74. newHiden=nil
  75. else
  76. newHidden="*"
  77. end
  78.  
  79. elseif y==13 then
  80.  
  81.  
  82. --Register-Screen
  83. paintutils.drawFilledBox(14,6,38,13,colors.black)
  84. term.setBackgroundColor(colors.orange)
  85. term.setCursorPos(15,7)
  86. print("Username:")
  87. term.setCursorPos(15,9)
  88. print("Password:")
  89. term.setCursorPos(15,11)
  90. print("confirm PW:")
  91. term.setBackgroundColor(colors.black)
  92. term.setCursorPos(14,13)
  93. term.setTextColor(colors.green)
  94. print("COMPLETE")
  95. term.setCursorPos(33,13)
  96. term.setTextColor(colors.red)
  97. print("cancel")
  98. term.setTextColor(colors.white)
  99. --Design
  100.  
  101. while verified==false do
  102. event,numb,x,y=os.pullEvent("mouse_click")
  103. term.setCursorPos(x,y)
  104.  
  105. if y==7 then
  106. paintutils.drawFilledBox(26,7,38,7,colors.black)
  107. term.setCursorPos(26,7)
  108. newUser=read()
  109.  
  110. elseif y==9 then
  111. paintutils.drawFilledBox(26,9,38,9,colors.black)
  112. term.setCursorPos(26,9)
  113. newPass=read()
  114.  
  115. elseif y==11 then
  116. paintutils.drawFilledBox(26,11,38,11,colors.black)
  117. term.setCursorPos(26,11)
  118. newPassC=read()
  119.  
  120. elseif y==13 and x>13 and x<20 then
  121. if newPass==newPassC then
  122.  
  123. if fs.exists("maxintosh/logindata/"..newUser) then
  124. term.setBackgroundColor(colors.red)
  125. term.setTextColor(colors.black)
  126. term.setCursorPos(19,4)
  127. write("User exists")
  128. sleep(2)
  129. shell.run("maxintosh/login")
  130. error()
  131. else
  132. file=fs.open("maxintosh/logindata/"..newUser,"w")
  133. file.writeLine(newPass)
  134. file.close()
  135. verified=true
  136. fs.copy("maxintosh/master","maxintosh/"..newUser)
  137. shell.run("maxintosh/login")
  138. error()
  139. end
  140.  
  141. elseif y==13 and x>24 and x<32 then
  142. verified=true
  143. shell.run("maxintosh/login")
  144. shell.run("clear")
  145. error()
  146.  
  147. end
  148.  
  149. end
  150.  
  151. end
  152. end
  153. end
  154.  
  155. if fs.exists("maxintosh/logindata/"..name) then
  156. file=fs.open("maxintosh/logindata/"..name,"r")
  157. readedPass=file.readLine()
  158. file.close()
  159. if readedPass==pass then
  160. found=true
  161. else
  162. found=false
  163. term.setCursorPos(19,4)
  164. term.setTextColor(colors.black)
  165. term.setBackgroundColor(colors.red)
  166. write("wrong password")
  167. sleep(1)
  168. end
  169. else
  170. found=false
  171. term.setBackgroundColor(colors.red)
  172. term.setTextColor(colors.black)
  173. term.setCursorPos(19,4)
  174. write(" unknown user")
  175. sleep(1)
  176. end
  177.  
  178.  
  179. if found==true then
  180. paintutils.drawFilledBox(1,1,51,51,colors.green)
  181. sleep(1)
  182. shell.run("clear")
  183. currentUser=name
  184. shell.run("maxintosh/desktop")
  185. else
  186. sleep(2)
  187. shell.run("maxintosh/login")
  188. end
Add Comment
Please, Sign In to add comment