Advertisement
Dojnaz

HZCity Browser

Oct 16th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. --Do not use
  2.  
  3. local stop
  4.  
  5. local function text(color)
  6. term.setTextColor(color)
  7. end
  8.  
  9. local function color(colo)
  10. term.setBackgroundColor(colo)
  11. end
  12.  
  13. local function pos(x, y)
  14. term.setCursorPos(x, y)
  15. end
  16.  
  17. local function yellowScreen()
  18. color(colors.yellow)
  19. term.clear()
  20. pos(1,1)
  21. text(colors.white)
  22. color(colors.green)
  23. term.write("Cookie Browser")
  24. color(colors.lime)
  25. term.write(" ")
  26. color(colors.red)
  27. pos(51,1)
  28. term.write("X")
  29. pos(1,19)
  30. color(colors.lime)
  31. term.write(" ")
  32. pos(1,3)
  33. color(colors.lime)
  34. term.write(" ")
  35. pos(1,2)
  36. text(colors.black)
  37. term.write(" >")
  38. color(colors.white)
  39. term.write(" ")
  40. color(colors.lime)
  41. pos(50,2)
  42. term.write(" ")
  43. pos(5, 8)
  44. color(colors.yellow)
  45. text(colors.black)
  46. term.write("Yellow Screen of Death")
  47. pos(5, 10)
  48. term.write("Can't connect to webpage")
  49. pos(5, 12)
  50. term.write("The server computer is not loaded")
  51. pos(5, 13)
  52. term.write("or the webpage does not exist")
  53. end
  54.  
  55. local function reset()
  56. term.clear()
  57. pos(1,1)
  58. text(colors.white)
  59. color(colors.green)
  60. term.write("Cookie Browser")
  61. color(colors.lime)
  62. term.write(" ")
  63. color(colors.red)
  64. pos(51,1)
  65. term.write("X")
  66. pos(1,19)
  67. color(colors.lime)
  68. term.write(" ")
  69. pos(1,3)
  70. color(colors.lime)
  71. term.write(" ")
  72. pos(1,2)
  73. text(colors.black)
  74. term.write(" >")
  75. color(colors.white)
  76. term.write(" ")
  77. color(colors.lime)
  78. pos(50,2)
  79. term.write(" ")
  80. end
  81.  
  82. xPos = 0
  83. yPos = 0
  84.  
  85. w, h = term.getSize()
  86.  
  87. local function drawClock()
  88.  
  89. color(colors.green)
  90. text(colors.white)
  91.  
  92. if os.time() >= 10 then
  93. xTime = 47
  94. else
  95. xTime = 48
  96. pos(47, 19)
  97. io.write("0")
  98. end
  99.  
  100. pos(xTime, 19)
  101. io.write(textutils.formatTime(os.time(), true))
  102. end
  103.  
  104. local function events()
  105.  
  106. event, p1, p2, p3 = os.pullEvent()
  107.  
  108. if event == "rednet_message" then
  109. return p2
  110. end
  111.  
  112. if event == "mouse_click" then
  113. xPos = p2
  114. yPos = p3
  115. button = p1
  116. browserClickPos()
  117. return "fail"
  118. end
  119.  
  120. if event == "alarm" and stop == nil then
  121. drawClock()
  122. return "fail"
  123. end
  124.  
  125. end
  126.  
  127. function browserClickPos()
  128.  
  129. if xPos == 51 and yPos == 1 then
  130. stop = true
  131. elseif xPos > 4 and xPos < 51 and yPos == 2 then
  132. pos(5,2)
  133. color(colors.white)
  134. term.write(" ")
  135. pos(5,2)
  136. text(colors.black)
  137. adress = read()
  138.  
  139. rednet.send(serverID, adress)
  140. repeat
  141. id = events()
  142. until id
  143.  
  144. if id ~= "fail" then
  145. rednet.send(id,1)
  146.  
  147. repeat
  148. id2 = events()
  149. until id2
  150. end
  151.  
  152. if id == "fail" or id2 == "fail" then
  153. yellowScreen()
  154. else
  155.  
  156. local num = 1
  157.  
  158. message = {}
  159.  
  160. webInfo = {color = {}, text = {}, tColor = {}, pos = {x = {}, y = {}}}
  161.  
  162. while message[6] == nil do
  163. rednet.send(id,num)
  164. id, message = rednet.receive()
  165.  
  166. webInfo.color[num] = message[1]
  167. webInfo.text[num] = message[2]
  168. webInfo.tColor[num] = message[3]
  169. webInfo.pos.x[num] = message[4]
  170. webInfo.pos.y[num] = message[5]
  171.  
  172. num = num + 1
  173. end
  174.  
  175. color(message[6])
  176. reset()
  177.  
  178. for i = 1,num-1 do
  179. color(webInfo.color[i])
  180. pos(webInfo.pos.x[i],webInfo.pos.y[i])
  181. text(webInfo.tColor[i])
  182. term.write(webInfo.text[i])
  183. end
  184.  
  185. end
  186. end
  187. end
  188.  
  189. local function clockUpdate()
  190.  
  191. while stop == nil do
  192.  
  193. if os.time() < 23.99 then
  194. os.setAlarm(os.time() + 0.01)
  195. else
  196. os.setAlarm(0)
  197. end
  198.  
  199. events()
  200.  
  201. end
  202.  
  203. end
  204.  
  205. if stop == nil then
  206. color(colors.white)
  207. reset()
  208.  
  209. color(colors.green)
  210. text(colors.white)
  211.  
  212. if os.time() >= 10 then
  213. xTime = 47
  214. else
  215. xTime = 48
  216. pos(47, 19)
  217. io.write("0")
  218. end
  219.  
  220. pos(xTime, 19)
  221. io.write(textutils.formatTime(os.time(), true))
  222.  
  223. clockUpdate()
  224. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement