Advertisement
cyber_Ahn

Command Remote

Jan 9th, 2016
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.07 KB | None | 0 0
  1. --Command Remote for Network Control--
  2. -- MONITOR was CHANGED in monitor.cfg--
  3. --optimal monitor size 5*4--
  4.  
  5. -- config--
  6. local channel = 43
  7. local backchan = 44
  8. modem = peripheral.wrap("back")
  9. local power = true
  10. local mon = ""
  11.  
  12. local b1 = "Toggle Rain"
  13. local b2 = "Sunrise"
  14. local b3 = "Midday"
  15. local b4 = "Sunset"
  16. local b5 = "Midnight"
  17. local b6 = "zero hour"
  18. local b7 = "World survival"
  19. local b8 = "World creative"
  20. local b9 = "Set Block"
  21. local b10 = "Weather rain"
  22. local b11 = "Weather clear"
  23. local b12 = "Weather thunder"
  24. local b13 = "Shutdown"
  25. local b14 = "Give Item"
  26. local b15 = "Give XP"
  27. local b16 = "Gamemode"
  28.  
  29. --var--
  30. local block = ""
  31. local give = ""
  32. local xp = ""
  33. local gm = ""
  34.  
  35. --load api
  36. shell.run("delete caAPI")
  37. shell.run("pastebin get EDLdR1nF caAPI")
  38. os.loadAPI("caAPI")
  39.  
  40. --set monitor
  41. function set_monitor()
  42. local monitor_number = caAPI.get_hardware("monitor")
  43. local found = fs.exists("config/monitor.cfg")
  44. if found == true then
  45. file = fs.open("config/monitor.cfg","r")
  46. local fileData = {}
  47. local line = file.readLine()
  48. repeat
  49. table.insert(fileData,line)
  50. line = file.readLine()
  51. until line == nil
  52. file.close()
  53. monitor_number = fileData[1]
  54. end
  55. mon = peripheral.wrap(monitor_number)
  56. end
  57.  
  58. --send data--
  59. function set_cable(data)
  60. modem.transmit(channel,backchan,data)
  61. end
  62.  
  63. --draw screen
  64. function draw_screen()
  65. mon.setBackgroundColor(colors.white)
  66. mon.setTextColor(colors.white)
  67. mon.clear()
  68. mon.setBackgroundColor(colors.white)
  69. mon.setCursorPos(1,1)
  70. mon.setBackgroundColor(colors.blue)
  71. mon.write("Command Remote      Channel:"..channel.."                     ")
  72. mon.setCursorPos(50,1)
  73. mon.setBackgroundColor(colors.red)
  74. mon.setTextColor(colors.black)
  75. mon.write("X")
  76. mon.setBackgroundColor(colors.white)
  77. mon.setCursorPos(1,2)
  78. mon.write(b1)
  79. mon.setCursorPos(2,3)
  80. mon.setBackgroundColor(colors.gray)
  81. mon.write("    ")
  82. mon.setBackgroundColor(colors.white)
  83. mon.setCursorPos(1,4)
  84. mon.write(b2)
  85. mon.setCursorPos(2,5)
  86. mon.setBackgroundColor(colors.gray)
  87. mon.write("    ")
  88. mon.setBackgroundColor(colors.white)
  89. mon.setCursorPos(1,6)
  90. mon.write(b3)
  91. mon.setCursorPos(2,7)
  92. mon.setBackgroundColor(colors.gray)
  93. mon.write("    ")
  94. mon.setBackgroundColor(colors.white)
  95. mon.setCursorPos(1,8)
  96. mon.write(b4)
  97. mon.setCursorPos(2,9)
  98. mon.setBackgroundColor(colors.gray)
  99. mon.write("    ")
  100. mon.setBackgroundColor(colors.white)
  101. mon.setCursorPos(1,10)
  102. mon.write(b5)
  103. mon.setCursorPos(2,11)
  104. mon.setBackgroundColor(colors.gray)
  105. mon.write("    ")
  106. mon.setBackgroundColor(colors.white)
  107. mon.setCursorPos(1,12)
  108. mon.write(b6)
  109. mon.setCursorPos(2,13)
  110. mon.setBackgroundColor(colors.gray)
  111. mon.write("    ")
  112. mon.setBackgroundColor(colors.white)
  113. mon.setCursorPos(1,14)
  114. mon.write(b7)
  115. mon.setCursorPos(2,15)
  116. mon.setBackgroundColor(colors.gray)
  117. mon.write("    ")
  118. mon.setBackgroundColor(colors.white)
  119. mon.setCursorPos(1,16)
  120. mon.write(b8)
  121. mon.setCursorPos(2,17)
  122. mon.setBackgroundColor(colors.gray)
  123. mon.write("    ")
  124. mon.setBackgroundColor(colors.white)
  125. mon.setCursorPos(1,18)
  126. mon.write(b9)
  127. mon.setCursorPos(2,19)
  128. mon.setBackgroundColor(colors.gray)
  129. mon.write("    ")
  130. mon.setBackgroundColor(colors.white)
  131. mon.setCursorPos(1,20)
  132. mon.write(b10)
  133. mon.setCursorPos(2,21)
  134. mon.setBackgroundColor(colors.gray)
  135. mon.write("    ")
  136. mon.setBackgroundColor(colors.white)
  137. mon.setCursorPos(1,22)
  138. mon.write(b11)
  139. mon.setCursorPos(2,23)
  140. mon.setBackgroundColor(colors.gray)
  141. mon.write("    ")
  142. mon.setBackgroundColor(colors.white)
  143. mon.setCursorPos(24,2)
  144. mon.write(b12)
  145. mon.setCursorPos(25,3)
  146. mon.setBackgroundColor(colors.gray)
  147. mon.write("    ")
  148. mon.setBackgroundColor(colors.white)
  149. mon.setCursorPos(24,4)
  150. mon.write(b13)
  151. mon.setCursorPos(25,5)
  152. mon.setBackgroundColor(colors.gray)
  153. mon.write("    ")
  154. mon.setBackgroundColor(colors.white)
  155. mon.setCursorPos(24,6)
  156. mon.write(b14)
  157. mon.setCursorPos(25,7)
  158. mon.setBackgroundColor(colors.gray)
  159. mon.write("    ")
  160. mon.setBackgroundColor(colors.white)
  161. mon.setCursorPos(24,8)
  162. mon.write(b15)
  163. mon.setCursorPos(25,9)
  164. mon.setBackgroundColor(colors.gray)
  165. mon.write("    ")
  166. mon.setBackgroundColor(colors.white)
  167. mon.setCursorPos(24,10)
  168. mon.write(b16)
  169. mon.setCursorPos(25,11)
  170. mon.setBackgroundColor(colors.gray)
  171. mon.write("    ")
  172. mon.setBackgroundColor(colors.white)
  173. touch()
  174. end
  175.  
  176. -- input block--
  177. function input_block()
  178. mon.setBackgroundColor(colors.white)
  179. mon.setTextColor(colors.black)
  180. mon.setCursorPos(1,26)
  181. mon.write("X:")
  182. block = "setblock#"
  183. input = read()
  184. block = block..input.."#"
  185. mon.write("Y:")
  186. input = read()
  187. block = block..input.."#"
  188. mon.write("Z:")
  189. input = read()
  190. block = block..input.."#"
  191. mon.write("Block Name/ID:")
  192. input = read()
  193. block = block..input
  194. set_cable(block)
  195. draw_screen()
  196. end
  197.  
  198. -- input give--
  199. function input_give()
  200. mon.setBackgroundColor(colors.white)
  201. mon.setTextColor(colors.black)
  202. mon.setCursorPos(1,26)
  203. mon.write("Player:")
  204. give = "give#"
  205. input = read()
  206. give = give..input.."#"
  207. mon.write("Block Name/ID:")
  208. input = read()
  209. give = give..input.."#"
  210. mon.write("Count:")
  211. input = read()
  212. give = give..input
  213. set_cable(give)
  214. draw_screen()
  215. end
  216.  
  217. -- input xp--
  218. function input_xp()
  219. mon.setBackgroundColor(colors.white)
  220. mon.setTextColor(colors.black)
  221. mon.setCursorPos(1,26)
  222. mon.write("XP:")
  223. xp = "xp#"
  224. input = read()
  225. xp = xp..input.."#"
  226. mon.write("Player:")
  227. input = read()
  228. xp = xp..input
  229. set_cable(xp)
  230. draw_screen()
  231. end
  232.  
  233. -- input gamemode--
  234. function input_gm()
  235. mon.setBackgroundColor(colors.white)
  236. mon.setTextColor(colors.black)
  237. mon.setCursorPos(1,26)
  238. mon.write("Modus:")
  239. gm = "gamemode#"
  240. input = read()
  241. gm = gm..input.."#"
  242. mon.write("Player:")
  243. input = read()
  244. gm = gm..input
  245. set_cable(gm)
  246. draw_screen()
  247. end
  248.  
  249. --touch event--
  250. function touch()
  251. event,side,x,y = os.pullEvent()
  252. if event == "monitor_touch" then
  253. if x == 50 and y == 1 then
  254. power = false
  255. end
  256. if x >= 2 and x <= 4 and y == 3 then
  257. set_cable("rain")
  258. draw_screen()
  259. end
  260. if x >= 2 and x <= 4 and y == 5 then
  261. set_cable("sunrise")
  262. draw_screen()
  263. end
  264. if x >= 2 and x <= 4 and y == 7 then
  265. set_cable("midday")
  266. draw_screen()
  267. end
  268. if x >= 2 and x <= 4 and y == 9 then
  269. set_cable("sunset")
  270. draw_screen()
  271. end
  272. if x >= 2 and x <= 4 and y == 11 then
  273. set_cable("midnight")
  274. draw_screen()
  275. end
  276. if x >= 2 and x <= 4 and y == 13 then
  277. set_cable("zero_hour")
  278. draw_screen()
  279. end
  280. if x >= 2 and x <= 4 and y == 15 then
  281. set_cable("world_survival")
  282. draw_screen()
  283. end
  284. if x >= 2 and x <= 4 and y == 17 then
  285. set_cable("world_creative")
  286. draw_screen()
  287. end
  288. if x >= 2 and x <= 4 and y == 19 then
  289. input_block()
  290. end
  291. if x >= 2 and x <= 4 and y == 21 then
  292. set_cable("weather_rain")
  293. draw_screen()
  294. end
  295. if x >= 2 and x <= 4 and y == 23 then
  296. set_cable("weather_clear")
  297. draw_screen()
  298. end
  299. if x >= 25 and x <= 29 and y == 3 then
  300. set_cable("weather_thunder")
  301. draw_screen()
  302. end
  303. if x >= 25 and x <= 29 and y == 5 then
  304. set_cable("shutdown")
  305. draw_screen()
  306. end
  307. if x >= 25 and x <= 29 and y == 7 then
  308. input_give()
  309. end
  310. if x >= 25 and x <= 29 and y == 9 then
  311. input_xp()
  312. end
  313. if x >= 25 and x <= 29 and y == 11 then
  314. input_gm()
  315. end
  316. end
  317. if power == true then
  318. draw_screen()
  319. else
  320. shell.run("clear")
  321. end
  322. end
  323.  
  324. --program--
  325. set_monitor()
  326. draw_screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement