Advertisement
NanoBob

forcefield map monitor

Sep 14th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.35 KB | None | 0 0
  1. monitor=peripheral.wrap("back")
  2. rednet.open("bottom")
  3.  
  4. mapInfo={
  5.  
  6. {13,1,128},
  7. {14,1,128},
  8. {15,1,128},
  9. {16,1,128},
  10. {17,1,128},
  11. {13,2,128},
  12. {14,2,256},
  13. {15,2,256},
  14. {16,2,256},
  15. {17,2,128},
  16. {13,3,128},
  17. {14,3,256},
  18. {15,3,256},
  19. {16,3,256},
  20. {17,3,128},
  21.  
  22. {13,4,128},
  23. {14,4,128},
  24. {15,4,128},
  25. {16,4,128},
  26. {17,4,128},
  27. {14,5,128},
  28. {15,5,256},
  29. {16,5,128},
  30. {14,6,256},
  31. {15,6,256},
  32. {16,6,128},
  33. {14,7,128},
  34. {15,7,256},
  35. {16,7,128},
  36. {14,8,128},
  37. {15,8,256},
  38. {16,8,128},
  39. {14,9,128},
  40. {15,9,256},
  41. {16,9,128},
  42. {14,10,128},
  43. {15,10,256},
  44. {16,10,128},
  45. {14,11,256},
  46. {15,11,256},
  47. {16,11,128},
  48. {14,12,128},
  49. {15,12,256},
  50. {16,12,256},
  51. {14,13,128},
  52. {15,13,256},
  53. {16,13,128},
  54. {14,14,128},
  55. {15,14,256},
  56. {16,14,128},
  57. {14,16,128},
  58. {15,16,256},
  59. {16,16,128},
  60. {14,15,256},
  61. {15,15,256},
  62. {16,15,128},
  63. {14,16,128},
  64. {15,16,128},
  65. {16,16,128},
  66.  
  67.  
  68.  
  69.  
  70. {11,10,128},
  71. {12,10,128},
  72. {13,10,128},
  73. {11,11,128},
  74. {12,11,256},
  75. {13,11,256},
  76. {11,12,128},
  77. {12,12,128},
  78. {13,12,128},
  79.  
  80. {11,14,128},
  81. {12,14,256},
  82. {13,14,128},
  83. {11,16,128},
  84. {12,16,256},
  85. {13,16,128},
  86. {11,15,128},
  87. {12,15,256},
  88. {13,15,256},
  89. {11,16,128},
  90. {12,16,256},
  91. {13,16,128},
  92. {11,16,128},
  93. {12,16,128},
  94. {13,16,128},
  95.  
  96.  
  97. {10,4,128},
  98. {11,4,128},
  99. {12,4,128},
  100. {13,4,128},
  101. {10,5,128},
  102. {11,5,256},
  103. {12,5,256},
  104. {13,5,256},
  105. {10,6,128},
  106. {11,6,256},
  107. {12,6,256},
  108. {13,6,256},
  109. {10,7,128},
  110. {11,7,256},
  111. {12,7,256},
  112. {13,7,256},
  113. {10,8,128},
  114. {11,8,128},
  115. {12,8,128},
  116. {13,8,128},
  117.  
  118. {17,11,128},
  119. {17,12,256},
  120. {17,13,128},
  121. {18,11,128},
  122. {18,12,256},
  123. {18,13,128},
  124.  
  125.  
  126. {18,7,128},
  127. {19,7,128},
  128. {20,7,128},
  129. {18,8,128},
  130. {19,8,256},
  131. {20,8,256},
  132. {18,9,128},
  133. {19,9,256},
  134. {20,9,256},
  135. {18,10,128},
  136. {19,10,256},
  137. {20,10,256},
  138. {18,11,128},
  139. {19,11,256},
  140. {20,11,256},
  141. {18,12,256},
  142. {19,12,256},
  143. {20,12,256},
  144. {18,13,128},
  145. {19,13,256},
  146. {20,13,256},
  147. {18,14,128},
  148. {19,14,256},
  149. {20,14,256},
  150. {18,15,128},
  151. {19,15,256},
  152. {20,15,256},
  153.  
  154. {21,7,128},
  155. {21,8,128},
  156. {21,9,128},
  157. {21,10,128},
  158. {21,11,128},
  159. {21,12,128},
  160. {21,13,128},
  161. {21,14,128},
  162. {21,15,128},
  163.  
  164.  
  165.  
  166. }
  167.  
  168. fieldsInfo={
  169. {15,4,"securityField",false},
  170. {14,11,"reactorField",false},
  171. {15,13,"hallwayfield",false},
  172. {18,12,"runwayField",false},
  173. }
  174.  
  175. function drawMap()
  176.   monitor.setBackgroundColor(32768)
  177.   monitor.clear()
  178.   for id,data in pairs(mapInfo) do
  179.     x=data[1]
  180.     y=data[2]
  181.     backGroundColor=data[3]
  182.     monitor.setCursorPos(x,y)
  183.     monitor.setBackgroundColor(backGroundColor)
  184.     monitor.write(" ")
  185.   end
  186.  
  187.   for id,data in pairs(fieldsInfo) do
  188.     x=data[1]
  189.     y=data[2]
  190.     monitor.setCursorPos(x,y)
  191.     monitor.setBackgroundColor(16384)
  192.     monitor.write(" ")
  193.   end
  194.  
  195. end
  196.  
  197. drawMap()
  198.  
  199. function checkPress()
  200.     event,side,x,y=os.pullEvent("monitor_touch")
  201.     for id,data in pairs(fieldsInfo) do
  202.         if x>=data[1]-1 and x<=data[1]+1 and y>=data[2]-1 and y<=data[2]+1 then
  203.             if data[4]==true then
  204.                 data[4]=false
  205.                 monitor.setBackgroundColor(16384)
  206.             else
  207.                 data[4]=true
  208.                 monitor.setBackgroundColor(8192)               
  209.             end
  210.             rednet.broadcast(data[3])
  211.             monitor.setCursorPos(data[1],data[2])
  212.             monitor.write(" ")
  213.         end
  214.     end
  215.     maxx,maxy=monitor.getSize()
  216.     monitor.setBackgroundColor(512)
  217.     monitor.setCursorPos(maxx-5,maxy)
  218.     x=tostring(x)
  219.     y=tostring(y)
  220.     if string.len(x)<2 then
  221.         x=" "..x
  222.     end
  223.     if string.len(y)<2 then
  224.         y=y.." "
  225.     end
  226.     monitor.write(x ..","..y)
  227.    
  228. end
  229.  
  230. while true do checkPress() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement