Advertisement
Guest User

startup

a guest
Dec 14th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1.  
  2. term.setBackgroundColor(colors.white)
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. term.setTextColor(colors.black)
  6. os.pullEvent()
  7. print("USE CTRL + R TO REBOOT AT ANYTIME")
  8. sleep(1)
  9. rednet.open("back")
  10. local server = 44
  11. local signal = 0
  12. local speed = 45
  13.  pingTime = 1000
  14.  untilPing = 0
  15. function ping()
  16. rednet.send(server, "connect")
  17. senderID, message, distance = rednet.receive(2)
  18. if message == "yes" then
  19. signal = 1
  20. home()
  21. menu()
  22. end
  23. end
  24.  
  25. function home()
  26. term.setBackgroundColor(colors.white)
  27. term.clear()
  28. term.setCursorPos(1,1)
  29. term.setTextColor(colors.red)
  30. term.write("E-Phone V.1")
  31. term.setCursorPos(20,1)
  32. if signal == 1 then
  33. term.write("Online!")
  34. else
  35. term.setCursorPos(19,1)
  36. term.write("Offline!")
  37. end
  38.  
  39. end
  40. function menu()
  41. term.setCursorPos(1,20)
  42. term.setBackgroundColor(colors.black)
  43. term.write("ADS")
  44. term.setCursorPos(23,20)
  45. term.write("Home")
  46. term.setCursorPos(6, 20)
  47. term.write("Chat")
  48. end
  49.  
  50.  
  51. function ads()
  52. home()
  53. end
  54.  
  55.  
  56. function chat()
  57. home()
  58. rednet.send(server, "chat")
  59. while true do
  60. senderID, message, distance = rednet.receive()
  61. if senderID == server then
  62. home()
  63. term.setCursorPos(1, 20)
  64. term.setBackgroundColor(colors.black)
  65. term.write("Write")
  66. term.setCursorPos(1, 2)
  67. term.write("Update")
  68. term.setCursorPos(8, 2)
  69. term.write("Home")
  70. term.setCursorPos(1, 3)
  71. term.setTextColor(colors.green)
  72. print(message)
  73. end
  74. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  75. if (xPos > 0 and xPos < 5) and (yPos > 19 and yPos < 21) then
  76. term.setCursorPos(6,20)
  77. term.write(":")
  78. input = read()
  79. home()
  80. rednet.send(server, "addchatt")
  81. sleep(0.5)
  82. rednet.send(server, input)
  83. sleep(0.5)
  84. chat()
  85. end
  86.  
  87. if (xPos > 0 and xPos < 7) and (yPos > 1 and yPos < 3) then
  88. chat()
  89. end
  90.  
  91. if (xPos > 6 and xPos < 11) and (yPos > 1 and yPos < 3) then
  92. ping()
  93. home()
  94. menu()
  95. break
  96. end
  97.  
  98. sleep(0.001)
  99. end
  100.  
  101. end
  102.  
  103.  
  104. function getAds()
  105. rednet.send(server, "ads")
  106. senderID, message, distance = rednet.receive(2)
  107. if (senderID == server) then
  108. term.setCursorPos(1,3)
  109. textutils.slowPrint(message, speed)
  110. else
  111. os.reboot()
  112. end
  113. end
  114.  
  115.  
  116. home()
  117. menu()
  118. ping()
  119.  
  120.  
  121. while true do
  122. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  123.  
  124. if (xPos > 0 and xPos < 4) and (yPos > 19 and yPos < 21) then
  125.  
  126. home()
  127. getAds()
  128. menu()
  129. end
  130.  
  131. if (xPos > 22 and xPos < 30) and (yPos > 19 and yPos < 23) then
  132. ping()
  133. home()
  134. menu()
  135. end
  136.  
  137. if (xPos > 5 and xPos < 11) and (yPos > 19 and yPos < 23) then
  138. chat()
  139. end
  140.  
  141. sleep(0.001)
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement