Advertisement
cyber_Ahn

cable remote

Dec 26th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.33 KB | None | 0 0
  1. --Bundled Cable Remote for Network Control--
  2. -- MONITOR was CHANGED in monitor.cfg--
  3. --optimal monitor size 5*4--
  4.  
  5. -- config--
  6. local channel = 21
  7. local backchan = 22
  8. modem = peripheral.wrap("back")
  9. local power = true
  10. local mon = ""
  11. --display name cable
  12. local white_na = "Light PC Room"
  13. local orange_na = "Light ME Room"
  14. local magenta_na = "Light Reactor"
  15. local lightblue_na = "Light Turbin"
  16. local yellow_na = "Light Tunnel"
  17. local lime_na = "lime"
  18. local pink_na = "pink"
  19. local grey_na = "gray"
  20. local lightgrey_na = "lightgray"
  21. local cyan_na = "cyan"
  22. local purple_na = "purple"
  23. local blue_na = "blue"
  24. local brown_na = "brown"
  25. local green_na = "green"
  26. local red_na = "red"
  27. local off_na = "All Off"
  28. local on_na = "All On"
  29.  
  30. --load api
  31. shell.run("delete caAPI")
  32. shell.run("pastebin get EDLdR1nF caAPI")
  33. os.loadAPI("caAPI")
  34.  
  35. --set monitor
  36. function set_monitor()
  37. local monitor_number = caAPI.get_hardware("monitor")
  38. local found = fs.exists("config/monitor.cfg")
  39. if found == true then
  40. file = fs.open("config/monitor.cfg","r")
  41. local fileData = {}
  42. local line = file.readLine()
  43. repeat
  44. table.insert(fileData,line)
  45. line = file.readLine()
  46. until line == nil
  47. file.close()
  48. monitor_number = fileData[1]
  49. end
  50. mon = peripheral.wrap(monitor_number)
  51. end
  52.  
  53. --draw screen
  54. function draw_screen()
  55. mon.setBackgroundColor(colors.white)
  56. mon.setTextColor(colors.white)
  57. mon.clear()
  58. mon.setBackgroundColor(colors.white)
  59. mon.setCursorPos(1,1)
  60. mon.setBackgroundColor(colors.blue)
  61. mon.write("Cabel Remote      Channel:"..channel.."                     ")
  62. mon.setCursorPos(50,1)
  63. mon.setBackgroundColor(colors.red)
  64. mon.setTextColor(colors.black)
  65. mon.write("X")
  66. mon.setBackgroundColor(colors.white)
  67. mon.setCursorPos(1,2)
  68. mon.write(white_na)
  69. mon.setCursorPos(2,3)
  70. mon.setBackgroundColor(colors.gray)
  71. mon.write("    ")
  72. mon.setBackgroundColor(colors.white)
  73. mon.setCursorPos(1,4)
  74. mon.write(orange_na)
  75. mon.setCursorPos(2,5)
  76. mon.setBackgroundColor(colors.gray)
  77. mon.write("    ")
  78. mon.setBackgroundColor(colors.white)
  79. mon.setCursorPos(1,6)
  80. mon.write(magenta_na)
  81. mon.setCursorPos(2,7)
  82. mon.setBackgroundColor(colors.gray)
  83. mon.write("    ")
  84. mon.setBackgroundColor(colors.white)
  85. mon.setCursorPos(1,8)
  86. mon.write(lightblue_na)
  87. mon.setCursorPos(2,9)
  88. mon.setBackgroundColor(colors.gray)
  89. mon.write("    ")
  90. mon.setBackgroundColor(colors.white)
  91. mon.setCursorPos(1,10)
  92. mon.write(yellow_na)
  93. mon.setCursorPos(2,11)
  94. mon.setBackgroundColor(colors.gray)
  95. mon.write("    ")
  96. mon.setBackgroundColor(colors.white)
  97. mon.setCursorPos(1,12)
  98. mon.write(lime_na)
  99. mon.setCursorPos(2,13)
  100. mon.setBackgroundColor(colors.gray)
  101. mon.write("    ")
  102. mon.setBackgroundColor(colors.white)
  103. mon.setCursorPos(1,14)
  104. mon.write(pink_na)
  105. mon.setCursorPos(2,15)
  106. mon.setBackgroundColor(colors.gray)
  107. mon.write("    ")
  108. mon.setBackgroundColor(colors.white)
  109. mon.setCursorPos(1,16)
  110. mon.write(grey_na)
  111. mon.setCursorPos(2,17)
  112. mon.setBackgroundColor(colors.gray)
  113. mon.write("    ")
  114. mon.setBackgroundColor(colors.white)
  115. mon.setCursorPos(1,18)
  116. mon.write(lightgrey_na)
  117. mon.setCursorPos(2,19)
  118. mon.setBackgroundColor(colors.gray)
  119. mon.write("    ")
  120. mon.setBackgroundColor(colors.white)
  121. mon.setCursorPos(1,20)
  122. mon.write(cyan_na)
  123. mon.setCursorPos(2,21)
  124. mon.setBackgroundColor(colors.gray)
  125. mon.write("    ")
  126. mon.setBackgroundColor(colors.white)
  127. mon.setCursorPos(1,22)
  128. mon.write(purple_na)
  129. mon.setCursorPos(2,23)
  130. mon.setBackgroundColor(colors.gray)
  131. mon.write("    ")
  132. mon.setBackgroundColor(colors.white)
  133. mon.setCursorPos(24,2)
  134. mon.write(blue_na)
  135. mon.setCursorPos(25,3)
  136. mon.setBackgroundColor(colors.gray)
  137. mon.write("    ")
  138. mon.setBackgroundColor(colors.white)
  139. mon.setCursorPos(24,4)
  140. mon.write(brown_na)
  141. mon.setCursorPos(25,5)
  142. mon.setBackgroundColor(colors.gray)
  143. mon.write("    ")
  144. mon.setBackgroundColor(colors.white)
  145. mon.setCursorPos(24,6)
  146. mon.write(green_na)
  147. mon.setCursorPos(25,7)
  148. mon.setBackgroundColor(colors.gray)
  149. mon.write("    ")
  150. mon.setBackgroundColor(colors.white)
  151. mon.setCursorPos(24,8)
  152. mon.write(red_na)
  153. mon.setCursorPos(25,9)
  154. mon.setBackgroundColor(colors.gray)
  155. mon.write("    ")
  156. mon.setBackgroundColor(colors.white)
  157. mon.setCursorPos(24,10)
  158. mon.write(off_na)
  159. mon.setCursorPos(25,11)
  160. mon.setBackgroundColor(colors.gray)
  161. mon.write("    ")
  162. mon.setBackgroundColor(colors.white)
  163. mon.setCursorPos(24,12)
  164. mon.write(on_na)
  165. mon.setCursorPos(25,13)
  166. mon.setBackgroundColor(colors.gray)
  167. mon.write("    ")
  168. mon.setBackgroundColor(colors.white)
  169. mon.setCursorPos(24,14)
  170. mon.write("Server shutdown")
  171. mon.setCursorPos(25,15)
  172. mon.setBackgroundColor(colors.gray)
  173. mon.write("    ")
  174. mon.setBackgroundColor(colors.white)
  175. touch()
  176. end
  177.  
  178. --touch event--
  179. function touch()
  180. event,side,x,y = os.pullEvent()
  181. if event == "monitor_touch" then
  182. if x == 50 and y == 1 then
  183. power = false
  184. end
  185. if x >= 2 and x <= 4 and y == 3 then
  186. set_cable("white")
  187. draw_screen()
  188. end
  189. if x >= 2 and x <= 4 and y == 5 then
  190. set_cable("orange")
  191. draw_screen()
  192. end
  193. if x >= 2 and x <= 4 and y == 7 then
  194. set_cable("magenta")
  195. draw_screen()
  196. end
  197. if x >= 2 and x <= 4 and y == 9 then
  198. set_cable("lightblue")
  199. draw_screen()
  200. end
  201. if x >= 2 and x <= 4 and y == 11 then
  202. set_cable("yellow")
  203. draw_screen()
  204. end
  205. if x >= 2 and x <= 4 and y == 13 then
  206. set_cable("lime")
  207. draw_screen()
  208. end
  209. if x >= 2 and x <= 4 and y == 15 then
  210. set_cable("pink")
  211. draw_screen()
  212. end
  213. if x >= 2 and x <= 4 and y == 17 then
  214. set_cable("gray")
  215. draw_screen()
  216. end
  217. if x >= 2 and x <= 4 and y == 19 then
  218. set_cable("lightgray")
  219. draw_screen()
  220. end
  221. if x >= 2 and x <= 4 and y == 21 then
  222. set_cable("cyan")
  223. draw_screen()
  224. end
  225. if x >= 2 and x <= 4 and y == 23 then
  226. set_cable("purple")
  227. draw_screen()
  228. end
  229. if x >= 25 and x <= 29 and y == 3 then
  230. set_cable("blue")
  231. draw_screen()
  232. end
  233. if x >= 25 and x <= 29 and y == 5 then
  234. set_cable("brown")
  235. draw_screen()
  236. end
  237. if x >= 25 and x <= 29 and y == 7 then
  238. set_cable("green")
  239. draw_screen()
  240. end
  241. if x >= 25 and x <= 29 and y == 9 then
  242. set_cable("red")
  243. draw_screen()
  244. end
  245. if x >= 25 and x <= 29 and y == 11 then
  246. set_cable("off")
  247. draw_screen()
  248. end
  249. if x >= 25 and x <= 29 and y == 13 then
  250. set_cable("on")
  251. draw_screen()
  252. end
  253. if x >= 25 and x <= 29 and y == 15 then
  254. set_cable("shutdown")
  255. draw_screen()
  256. end
  257. end
  258. if power == true then
  259. draw_screen()
  260. else
  261. shell.run("clear")
  262. end
  263. end
  264.  
  265. --send cable data--
  266. function set_cable(data)
  267. modem.transmit(channel,backchan,data)
  268. end
  269.  
  270. --program--
  271. set_monitor()
  272. draw_screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement