Advertisement
Guest User

ClientSideV4

a guest
Dec 12th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. local component = require("component")
  2. local event = require("event")
  3. local term = require("term")
  4. local serialization = require("serialization")
  5. local m = component.modem
  6. m.setStrength(10000)
  7. m.open(1)
  8.  
  9. function getn(t)
  10. local count = 0
  11. for _ in pairs(t) do count = count + 1 end
  12. return count
  13. end
  14.  
  15. function push_back(l, new_item)
  16. l[getn(l)+1] = new_item
  17. end
  18.  
  19. local server = "289482dd-8962-4d7a-a662-e545001f4964"
  20. local input
  21. local output
  22. local in2 = { }
  23.  
  24. term.clear()
  25.  
  26. while true do
  27. input = ""
  28. in2 = { }
  29.  
  30. io.write("type 'help' for list of commands\n\n")
  31.  
  32. input = io.read()
  33. push_back(in2, input)
  34.  
  35. if (in2[1] == "change_password") then
  36. term.clear()
  37. print("enter username\n")
  38. input = io.read()
  39. push_back(in2, input)
  40.  
  41. term.clear()
  42. print("enter old password:\n")
  43. input = io.read()
  44. push_back(in2, input)
  45.  
  46. term.clear()
  47. print("enter new password:\n")
  48. input = io.read()
  49. push_back(in2, input)
  50.  
  51. term.clear()
  52.  
  53. elseif (in2[1] == "send") then
  54. term.clear()
  55. print("enter your username\n")
  56. input = io.read()
  57. push_back(in2, input)
  58.  
  59. term.clear()
  60. print("enter username of person your sending to\n")
  61. input = io.read()
  62. push_back(in2, input)
  63.  
  64. term.clear()
  65. print("enter amount you are sending\n")
  66. input = io.read()
  67. push_back(in2, input)
  68.  
  69. term.clear()
  70. print("enter password for your account\n")
  71. input = io.read()
  72. push_back(in2, input)
  73. elseif(in2[1] == "balance") then
  74. term.clear()
  75. print("enter username\n")
  76. input = io.read()
  77. push_back(in2, input)
  78.  
  79. term.clear()
  80. print("enter password\n")
  81. input = io.read()
  82. push_back(in2, input)
  83. elseif(in2[1] == "add_user") then
  84. term.clear()
  85. print("enter username\n")
  86. input = io.read()
  87. push_back(in2, input)
  88.  
  89. term.clear()
  90. print("enter password\n")
  91. input = io.read()
  92. push_back(in2, input)
  93.  
  94. term.clear()
  95. print("enter balance\n")
  96. input = io.read()
  97. push_back(in2, input)
  98.  
  99. term.clear()
  100. print("enter admin pass\n")
  101. input = io.read()
  102. push_back(in2, input)
  103. elseif(in2[1] == "list") then
  104. term.clear()
  105. print("enter admin pass")
  106. input = io.read()
  107. push_back(in2, input)
  108. elseif(in2[1] == "help") then
  109. term.clear()
  110. print("changePassword: Changes account password, duh")
  111. print("send : Send money from one user to another")
  112. print("balance : Prints your Balance to screen")
  113. print("list : Lists All users balance")
  114. os.sleep(10)
  115. term.clear()
  116. end
  117.  
  118. if(in2[1] ~= "help") then
  119. m.send(server, 1, serialization.serialize(in2) )
  120. local _, _, from, port, distance, message = event.pull(5, "modem_message")
  121.  
  122. if(type(distance) ~= "nil") then
  123. local strength = (distance+1000)
  124. m.setStrength(strength)
  125. print(from)
  126. end
  127. if( (from == server) and (message ~= "I") and (message ~= "H") ) then
  128. term.clear()
  129. output = serialization.unserialize(message)
  130. print( tostring(output[getn(output)]) )
  131. os.sleep(10)
  132. term.clear()
  133. end
  134. end
  135. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement