Advertisement
Guest User

update

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