Advertisement
Guest User

update

a guest
Dec 15th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.84 KB | None | 0 0
  1. --Written by epa1337
  2. --You can not steal this
  3. --Because that makes you
  4. --a bad person
  5. term.setBackgroundColor(colors.white)
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. term.setTextColor(colors.black)
  9.  
  10. print("USE CTRL + R TO REBOOT AT ANYTIME")
  11. print("")
  12. print("OK")
  13.  
  14.  
  15. rednet.open("back")
  16. local server1 = 44
  17. local server = 0
  18. rednet.broadcast("connect")
  19. local senderID, message, distance = rednet.receive(3)
  20.  
  21. if message == "yes" then
  22. server = senderID
  23. end
  24. sleep(1)
  25. local signal = 0
  26. local speed = 45
  27. local version = 1
  28.  pingTime = 1000
  29.  untilPing = 0
  30. function ping()
  31. rednet.send(server, "connect")
  32. senderID, message, distance = rednet.receive(2)
  33. if message == "yes" then
  34. signal = 1
  35. home()
  36. menu()
  37. end
  38. end
  39.  
  40. function home()
  41. term.setBackgroundColor(colors.white)
  42. term.clear()
  43. term.setCursorPos(1,1)
  44. term.setTextColor(colors.red)
  45. term.write("E-Phone "..version)
  46. term.setCursorPos(20,1)
  47. if signal == 1 then
  48. term.write("Online!")
  49. else
  50. term.setCursorPos(19,1)
  51. term.write("Offline!")
  52. end
  53.  
  54. end
  55. function menu()
  56. term.setCursorPos(1,20)
  57. term.setBackgroundColor(colors.black)
  58. term.write("Ads")
  59. term.setCursorPos(23,20)
  60. term.write("Home")
  61. term.setCursorPos(6, 20)
  62. term.write("Chat")
  63. term.setCursorPos(12, 20)
  64. term.write("EpaNet")
  65. end
  66. function sorry()
  67. home()
  68. term.setCursorPos(1, 3)
  69. print("Sorry. You are connected to a repeater, you need to be near the EpaNet-building at this moment to do this. Thank you")
  70. sleep(4)
  71. home()
  72. menu()
  73. end
  74.  
  75.  
  76. function ads()
  77. home()
  78. end
  79.  
  80. function epanet()
  81. home()
  82. menu()
  83. term.setCursorPos(1, 3)
  84. term.setBackgroundColor(colors.black)
  85. term.setTextColor(colors.red)
  86. print("Send Text")
  87. print("Read Texts")
  88. print("Empty Texts")
  89. print("")
  90. print("GPS")
  91. print("")
  92. print("Maps")
  93. print("")
  94. print("Update!")
  95. end
  96.  
  97. function chat()
  98. home()
  99. rednet.send(server, "chat")
  100. while true do
  101. senderID, message, distance = rednet.receive()
  102. if senderID == server then
  103. home()
  104. term.setCursorPos(1, 20)
  105. term.setBackgroundColor(colors.black)
  106. term.write("Write")
  107. term.setCursorPos(1, 2)
  108. term.write("Update")
  109. term.setCursorPos(8, 2)
  110. term.write("Home")
  111. term.setCursorPos(1, 3)
  112. term.setTextColor(colors.green)
  113. print(message)
  114. end
  115. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  116. if (xPos > 0 and xPos < 5) and (yPos > 19 and yPos < 21) then
  117. term.setCursorPos(6,20)
  118. term.write(":")
  119. input = read()
  120. home()
  121. rednet.send(server, "addchatt")
  122. sleep(0.5)
  123. rednet.send(server, input)
  124. sleep(1)
  125. chat()
  126. end
  127.  
  128. if (xPos > 0 and xPos < 7) and (yPos > 1 and yPos < 3) then
  129. chat()
  130. end
  131.  
  132. if (xPos > 6 and xPos < 11) and (yPos > 1 and yPos < 3) then
  133. ping()
  134. home()
  135. menu()
  136. break
  137. end
  138.  
  139. sleep(0.001)
  140. end
  141.  
  142. end
  143.  
  144.  
  145. function getAds()
  146. rednet.send(server, "ads")
  147. senderID, message, distance = rednet.receive(2)
  148. if (senderID == server) then
  149. term.setCursorPos(1,3)
  150. print(message)
  151. else
  152. os.reboot()
  153. end
  154. end
  155.  
  156.  
  157. home()
  158. menu()
  159. ping()
  160.  
  161.  
  162. while true do
  163.  
  164. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  165.  
  166.  
  167. if event == "terminate" then
  168. os.reboot()
  169. end
  170. if (xPos > 0 and xPos < 11) and (yPos > 2 and yPos < 4) then
  171. home()
  172. menu()
  173. end
  174. if (xPos > 0 and xPos < 7) and (yPos > 10 and yPos < 12) then
  175. if server == server1 then
  176. rednet.send(server, "update")
  177. local sender,msg,dist = rednet.receive(2)
  178. if sender == server then
  179. local file = fs.open("startup", "w")
  180. file.write(msg)
  181. file.close()
  182. home()
  183. term.setCursorPos(1, 3)
  184. print("Updated!")
  185. sleep(2)
  186. os.reboot()
  187. end
  188. else
  189. sorry()
  190. end
  191. end
  192.  
  193. if (xPos > 0 and xPos < 4) and (yPos > 19 and yPos < 21) then
  194.  
  195. home()
  196. getAds()
  197. menu()
  198. end
  199.  
  200. if (xPos > 22 and xPos < 30) and (yPos > 19 and yPos < 23) then
  201. ping()
  202. home()
  203. menu()
  204. end
  205.  
  206. if (xPos > 5 and xPos < 11) and (yPos > 19 and yPos < 23) then
  207. if server == server1 then
  208. chat()
  209. else
  210. sorry()
  211. end
  212. end
  213.  
  214. if (xPos > 11 and xPos < 18) and (yPos > 19 and yPos < 23) then
  215. epanet()
  216. end
  217. sleep(0.001)
  218. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement