Advertisement
Guest User

loginClient

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