Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. m = peripheral.wrap("monitor_0")
  2. rednet.open("left")
  3.  
  4. local slate1 = 0
  5. local slate2 = 0
  6. local slate3 = 0
  7. local slate4 = 0
  8. local slate5 = 0
  9.  
  10. function allOff()
  11. for i = 43, 47 do
  12. rednet.send(i, "0")
  13. end
  14. sleep(0.5)
  15. end
  16.  
  17. function check()
  18. event, side, xi, yi = os.pullEvent("monitor_touch")
  19. for y = 2,4 do
  20. for x = 4,6 do
  21. if xi == x and yi == y then
  22. if slate1 == 1 then
  23. slate1 = 0
  24. allOff()
  25. rednet.send(43, "0")
  26. else
  27. slate1 = 1
  28. slate2 = 0
  29. slate3 = 0
  30. slate4 = 0
  31. slate5 = 0
  32. allOff()
  33. rednet.send(43, "1")
  34. end
  35. end
  36. end
  37. for x = 9,11 do
  38. if xi == x and yi == y then
  39. if slate2 == 1 then
  40. slate2 = 0
  41. allOff()
  42. rednet.send(44, "0")
  43. else
  44. slate1 = 0
  45. slate2 = 1
  46. slate3 = 0
  47. slate4 = 0
  48. slate5 = 0
  49. allOff()
  50. rednet.send(44, "1")
  51. end
  52. end
  53. end
  54. for x = 14,16 do
  55. if xi == x and yi == y then
  56. if slate3 == 1 then
  57. slate3 = 0
  58. allOff()
  59. rednet.send(45, "0")
  60. else
  61. slate1 = 0
  62. slate2 = 0
  63. slate3 = 1
  64. slate4 = 0
  65. slate5 = 0
  66. allOff()
  67. rednet.send(45, "1")
  68. end
  69. end
  70. end
  71. for x = 19, 21 do
  72. if xi == x and yi == y then
  73. if slate4 == 1 then
  74. slate4 = 0
  75. allOff()
  76. rednet.send(46, "0")
  77. else
  78. slate1 = 0
  79. slate2 = 0
  80. slate3 = 0
  81. slate4 = 1
  82. slate5 = 0
  83. allOff()
  84. rednet.send(46, "1")
  85. end
  86. end
  87. end
  88. for x = 24,26 do
  89. if xi == x and yi == y then
  90. if slate5 == 1 then
  91. slate5 = 0
  92. allOff()
  93. rednet.send(47, "0")
  94. else
  95. slate1 = 0
  96. slate2 = 0
  97. slate3 = 0
  98. slate4 = 0
  99. slate5 = 1
  100. allOff()
  101. rednet.send(47, "1")
  102. end
  103. end
  104. end
  105. end
  106. end
  107.  
  108. function print()
  109. m.setBackgroundColor(32768)
  110. m.clear()
  111. m.setCursorPos(9,1)
  112. m.write("Slate-Control")
  113.  
  114. for y = 2,4 do
  115. for x = 4,6 do
  116. m.setCursorPos(x,y)
  117. if slate1 == 0 then
  118. m.setBackgroundColor(16384)
  119. else
  120. m.setBackgroundColor(8192)
  121. end
  122. if x == 5 and y == 3 then
  123. m.write("1")
  124. else
  125. m.write(" ")
  126. end
  127. end
  128.  
  129. for x = 9,11 do
  130. m.setCursorPos(x,y)
  131. if slate2 == 0 then
  132. m.setBackgroundColor(16384)
  133. else
  134. m.setBackgroundColor(8192)
  135. end
  136. if x == 10 and y == 3 then
  137. m.write("2")
  138. else
  139. m.write(" ")
  140. end
  141. end
  142.  
  143. for x = 14,16 do
  144. m.setCursorPos(x,y)
  145. if slate3 == 0 then
  146. m.setBackgroundColor(16384)
  147. else
  148. m.setBackgroundColor(8192)
  149. end
  150. if x == 15 and y == 3 then
  151. m.write("3")
  152. else
  153. m.write(" ")
  154. end
  155. end
  156.  
  157. for x = 19,21 do
  158. m.setCursorPos(x,y)
  159. if slate4 == 0 then
  160. m.setBackgroundColor(16384)
  161. else
  162. m.setBackgroundColor(8192)
  163. end
  164. if x == 20 and y == 3 then
  165. m.write("4")
  166. else
  167. m.write(" ")
  168. end
  169. end
  170.  
  171. for x = 24,26 do
  172. m.setCursorPos(x,y)
  173. if slate5 == 0 then
  174. m.setBackgroundColor(16384)
  175. else
  176. m.setBackgroundColor(8192)
  177. end
  178. if x == 25 and y == 3 then
  179. m.write("5")
  180. else
  181. m.write(" ")
  182. end
  183. end
  184. end
  185. end
  186.  
  187. sleep(1)
  188. allOff()
  189. print()
  190. while true do
  191. check()
  192. print()
  193. sleep(0.1)
  194. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement