Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. function register()
  2. term.clear()
  3. term.setCursorPos(51,1)
  4. term.setBackgroundColor(colors.red)
  5. write("X")
  6. term.setBackgroundColor(colors.black)
  7. term.setCursorPos(10,3)
  8. write("diamondpumpkin's Banking Client")
  9. term.setCursorPos(18,7)
  10. write("Login - ")
  11. term.setTextColor(colors.lightBlue)
  12. term.setCursorPos(27,7)
  13. write("Register")
  14. term.setTextColor(colors.white)
  15. term.setCursorPos(18,8)
  16. write("Username: ")
  17. local input = read()
  18. user = input
  19. term.setCursorPos(18,9)
  20. write("Password: ")
  21. local input = read("*")
  22. pass = input
  23. rednet.send(16, "register", "bank")
  24. local id, message = rednet.receive()
  25. if id == 16 then
  26. if message == "Already logged in." then
  27. return
  28. elseif message == "Ready." then
  29. sleep(0.2)
  30. rednet.send(16, user, "bank")
  31. sleep(0.2)
  32. rednet.send(16, pass, "bank")
  33. end
  34. end
  35. end
  36.  
  37. function login()
  38. term.clear()
  39. term.setCursorPos(51,1)
  40. term.setBackgroundColor(colors.red)
  41. write("X")
  42. term.setBackgroundColor(colors.black)
  43. term.setCursorPos(10,3)
  44. write("diamondpumpkin's Banking Client")
  45. term.setCursorPos(18,7)
  46. term.setTextColor(colors.lightBlue)
  47. write("Login ")
  48. term.setTextColor(colors.white)
  49. term.setCursorPos(24,7)
  50. write("- Register")
  51. term.setCursorPos(18,8)
  52. write("Username: ")
  53. local input = read()
  54. user = input
  55. term.setCursorPos(18,9)
  56. write("Password: ")
  57. local input = read("*")
  58. pass = input
  59. rednet.send(16, "login", "bank")
  60. local id, message = rednet.receive()
  61. if id == 16 then
  62. elseif message == "Ready." then
  63. sleep(0.2)
  64. rednet.send(16, user, "bank")
  65. sleep(0.2)
  66. rednet.send(16, pass, "bank")
  67. local id, message = rednet.receive()
  68. if id == 16 then
  69. term.setCursorPos(18,10)
  70. write(message)
  71. sleep(1)
  72. if message == "Already logged in." or message == "Logged in." then
  73. main()
  74. return
  75. elseif message == "Incorrect password." then
  76. return
  77. end
  78. end
  79. end
  80. end
  81. end
  82.  
  83. function main()
  84. term.clear()
  85. term.setCursorPos(1,1)
  86. x = 0
  87. y = 1
  88. while true do
  89. x = x + 1
  90. if y == 20 then
  91. break
  92. end
  93. if x == 8 then
  94. y = y + 1
  95. x = 0
  96. end
  97. term.setCursorPos(x,y)
  98. term.setTextColor(colors.lightBlue)
  99. term.setBackgroundColor(colors.lightBlue)
  100. write(".")
  101. end
  102. term.setTextColor(colors.white)
  103. term.setCursorPos(1,1)
  104. write("Balance")
  105. term.setCursorPos(1,2)
  106. write("Send")
  107. term.setCursorPos(1,3)
  108. write("Account")
  109. term.setCursorPos(1,4)
  110. write("Logout")
  111. term.setCursorPos(1,20)
  112.  
  113. while true do
  114. local event, button, x, y = os.pullEvent( "mouse_click" )
  115. if x >= 1 and x <= 7 and y == 1 then
  116. balance()
  117. end
  118. end
  119. end
  120.  
  121.  
  122. rednet.open("top")
  123. term.clear()
  124. term.setCursorPos(51,1)
  125. term.setBackgroundColor(colors.red)
  126. write("X")
  127. term.setBackgroundColor(colors.black)
  128. term.setCursorPos(10,3)
  129. write("diamondpumpkin's Banking Client")
  130. term.setCursorPos(18,7)
  131. write("Login - Register")
  132. while true do
  133. local event, button, x, y = os.pullEvent( "mouse_click" )
  134. if x >= 18 and x <= 22 and y == 7 then
  135. login()
  136. elseif x >= 26 and x <= 33 and y == 7 then
  137. register()
  138. elseif x == 51 and y == 1 then
  139. term.clear()
  140. term.setCursorPos(1,1)
  141. break
  142. end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement