Advertisement
NanoBob

forecefield map control

Sep 10th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.75 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,128},
  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.  
  119.  
  120.  
  121. }
  122.  
  123. fieldsInfo={
  124. {15,4,"securityField",false},
  125. {14,11,"reactorfield",false},
  126. {15,13,"hallwayfield",false},
  127. }
  128.  
  129. function drawMap()
  130.   monitor.setBackgroundColor(32768)
  131.   monitor.clear()
  132.   for id,data in pairs(mapInfo) do
  133.     x=data[1]
  134.     y=data[2]
  135.     backGroundColor=data[3]
  136.     monitor.setCursorPos(x,y)
  137.     monitor.setBackgroundColor(backGroundColor)
  138.     monitor.write(" ")
  139.   end
  140.  
  141.   for id,data in pairs(fieldsInfo) do
  142.     x=data[1]
  143.     y=data[2]
  144.     monitor.setCursorPos(x,y)
  145.     monitor.setBackgroundColor(16384)
  146.     monitor.write(" ")
  147.   end
  148.  
  149. end
  150.  
  151. drawMap()
  152.  
  153. function checkPress()
  154.     event,side,x,y=os.pullEvent("monitor_touch")
  155.     for id,data in pairs(fieldsInfo) do
  156.         if x>=data[1]-1 and x<=data[1]+1 and y>=data[2]-1 and y<=data[2]+1 then
  157.             if data[4]==true then
  158.                 data[4]=false
  159.                 monitor.setBackgroundColor(16384)
  160.             else
  161.                 data[4]=true
  162.                 monitor.setBackgroundColor(8192)               
  163.             end
  164.             rednet.broadcast(data[3])
  165.             monitor.setCursorPos(data[1],data[2])
  166.             monitor.write(" ")
  167.         end
  168.     end
  169.     maxx,maxy=monitor.getSize()
  170.     monitor.setBackgroundColor(512)
  171.     monitor.setCursorPos(maxx-5,maxy)
  172.     x=tostring(x)
  173.     y=tostring(y)
  174.     if string.len(x)<2 then
  175.         x=" "..x
  176.     end
  177.     if string.len(y)<2 then
  178.         y=y.." "
  179.     end
  180.     monitor.write(x ..","..y)
  181.    
  182. end
  183.  
  184. while true do checkPress() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement