xXm0dzXx

Untitled

Jul 16th, 2012
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. rednet.open("top")
  2. local bankID = 102;
  3. local w, h = term.getSize()
  4.  
  5. function cPrint(str, ypos)
  6. term.setCursorPos(w/2-#str/2, ypos)
  7. write(str)
  8. end
  9.  
  10. function clear()
  11. term.clear()
  12. term.setCursorPos(1,1)
  13. end
  14.  
  15. print("Entering fullscreen in 3...")
  16. sleep(1)
  17. print("2...")
  18. sleep(1)
  19. print("1...")
  20. sleep(1)
  21. selection = 1
  22.  
  23. while true do
  24. clear()
  25. if selection == 1 then
  26. print("> Login < Register \n")
  27. else
  28. print(" Login > Register <\n")
  29. end
  30.  
  31. cPrint("+-------------------+", 3)
  32. cPrint("| |", 4)
  33. cPrint("| Username: |", 5)
  34. cPrint("| Password: |", 6)
  35. cPrint("| |", 7)
  36. cPrint("+-------------------+", 8)
  37.  
  38. local event, key = os.pullEvent("key")
  39.  
  40. if key == 203 then
  41. selection = 1
  42. elseif key == 205 then
  43. selection = 94897983697
  44. elseif key == 28 then
  45. break
  46. end
  47. end
  48.  
  49. statusMessage = "| |"
  50.  
  51. function login()
  52. while true do
  53. clear()
  54. cPrint("+-------------------+", 3)
  55. cPrint(statusMessage, 4)
  56. cPrint("| Username: |", 5)
  57. cPrint("| Password: |", 6)
  58. cPrint("| |", 7)
  59. cPrint("+-------------------+", 8)
  60.  
  61. str = "| Username: |"
  62. map = w/2-#str/2+string.len("| Username: ")
  63. term.setCursorPos(map, 5)
  64. username = read()
  65. term.setCursorPos(map, 6)
  66. if selection == 1 then
  67. a = "*"
  68. else
  69. a = nil
  70. end
  71.  
  72. password = read(a)
  73.  
  74. if username == "" or password == "" then
  75. statusMessage = "| Fill in all areas |"
  76. elseif selection == 1 then
  77. rednet.send(bankID, "VERIFY:" ..username.. ":" ..password)
  78. repeat
  79. id, message = rednet.receive()
  80. until id == bankID
  81.  
  82. if message == "Correct" then
  83. break
  84. else
  85. statusMessage = "| Login failed. |"
  86. end
  87. else
  88. break
  89. end
  90. end
  91. end
  92.  
  93. login()
  94.  
  95. if username == "" and password == "" then
  96. clear()
  97. shell.run("shell")
  98. else
  99. if selection == 94897983697 then
  100. rednet.send(bankID, "NEW:" ..username.. ":" ..password)
  101. end
  102.  
  103. function updateBalance()
  104. rednet.send(bankID, "CHECK:" ..username)
  105. repeat
  106. id, balance = rednet.receive()
  107. until id == bankID
  108.  
  109. print("Balance: " ..balance.. "$ (CTRL = Update)")
  110. end
  111.  
  112. function hai()
  113. clear()
  114. print("Welcome, " ..username.. "!")
  115. updateBalance()
  116. for i=1,w-1 do
  117. write("-")
  118. end
  119.  
  120. print("Recent Actions: ")
  121. print("<Coming Soon>\n")
  122. print("Press Enter to donate.")
  123. print("Press SHIFT to logout.")
  124. while true do
  125. event, key = os.pullEvent("key")
  126. if key == 42 then
  127. login()
  128. elseif key == 29 then
  129. hai()
  130. elseif key == 28 then
  131. donate()
  132. end
  133. end
  134. end
  135.  
  136. function donate()
  137. clear()
  138. write("Who would you like to donate to? ")
  139. input = read()
  140. write("How much would you like to donate? $")
  141. test = read()
  142.  
  143. --GIVE:<YOUR NAME>:<YOUR PASS>:<HOW MUCH U WANNA GIVE TO...>:<YOUR FRIEND>
  144. rednet.send(bankID, "GIVE:" ..username.. ":" ..password.. ":" ..test.. ":" ..input)
  145. hai()
  146. end
  147.  
  148. hai()
  149. end
Advertisement
Add Comment
Please, Sign In to add comment