joshgreatuk

Red Alert 1.0

Jul 30th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.50 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. function ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  3. term.clear()
  4. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  5. paintutils.drawBox(1,1,51,19,colors.blue)
  6. term.setBackgroundColor(colors.lightBlue)
  7. term.setCursorPos(3,3)
  8. print("Control This Computer's Output")
  9. x1,y1 = 3,5
  10. x2,y2 = 3,7
  11. x3,y3 = 3,9
  12. x4,y4 = 3,11
  13. x5,y5 = 3,13
  14. x6,y6 = 3,15
  15. x7,y7 = 3,17
  16. choice1 = " Left "
  17. choice2 = " Right "
  18. choice3 = " Front "
  19. choice4 = " Back "
  20. choice5 = " Top "
  21. choice6 = " Bottom "
  22. choice7 = " Exit "
  23. term.setBackgroundColor(colors.red)
  24. term.setCursorPos(x1,y1)
  25. write(choice1)
  26. term.setCursorPos(x2,y2)
  27. write(choice2)
  28. term.setCursorPos(x3,y3)
  29. write(choice3)
  30. term.setCursorPos(x4,y4)
  31. write(choice4)
  32. term.setCursorPos(x5,y5)
  33. write(choice5)
  34. term.setCursorPos(x6,y6)
  35. write(choice6)
  36. term.setCursorPos(x7,y7)
  37. write(choice7)
  38. while true do
  39. local event, button, cx, cy = os.pullEvent()
  40. if event == "mouse_click" then
  41. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  42. term.clear()
  43. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  44. paintutils.drawBox(1,1,51,19,colors.blue)
  45. term.setBackgroundColor(colors.lightBlue)
  46. term.setCursorPos(3,3)
  47. print("Turn Left Output On Or Off?")
  48. local x1,y1 = 3,6
  49. local x2,y2 = 3,8
  50. local x3,y3 = 3,10
  51. local choice1 = " On "
  52. local choice2 = " Off "
  53. local choice3 = " Exit "
  54. term.setBackgroundColor(colors.red)
  55. term.setCursorPos(x1,y1)
  56. write(choice1)
  57. term.setCursorPos(x2,y2)
  58. write(choice2)
  59. term.setCursorPos(x3,y3)
  60. write(choice3)
  61. while true do
  62. local event, button, cx, cy = os.pullEvent()
  63. if event == "mouse_click" then
  64. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  65. redstone.setOutput("left",true)
  66. f = fs.open(leftf,"w")
  67. f.write("1")
  68. f.close()
  69. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  70. break
  71. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  72. redstone.setOutput("left",false)
  73. f = fs.open(leftf,"w")
  74. f.write("0")
  75. f.close()
  76. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  77. break
  78. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  79. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  80. break
  81. end
  82. end
  83. end
  84. end
  85. end
  86. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  87. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  88. term.clear()
  89. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  90. paintutils.drawBox(1,1,51,19,colors.blue)
  91. term.setBackgroundColor(colors.lightBlue)
  92. term.setCursorPos(3,3)
  93. print("Turn Right Output On Or Off?")
  94. local x1,y1 = 3,6
  95. local x2,y2 = 3,8
  96. local x3,y3 = 3,10
  97. local choice1 = " On "
  98. local choice2 = " Off "
  99. local choice3 = " Exit "
  100. term.setBackgroundColor(colors.red)
  101. term.setCursorPos(x1,y1)
  102. write(choice1)
  103. term.setCursorPos(x2,y2)
  104. write(choice2)
  105. term.setCursorPos(x3,y3)
  106. write(choice3)
  107. while true do
  108. local event, button, cx, cy = os.pullEvent()
  109. if event == "mouse_click" then
  110. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  111. redstone.setOutput("right",true)
  112. f = fs.open(rightf,"w")
  113. f.write("1")
  114. f.close()
  115. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  116. break
  117. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  118. redstone.setOutput("right",false)
  119. f = fs.open(rightf,"w")
  120. f.write("0")
  121. f.close()
  122. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  123. break
  124. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  125. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  126. break
  127. end
  128. end
  129. end
  130. end
  131. end
  132. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  133. break
  134. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  135. term.clear()
  136. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  137. paintutils.drawBox(1,1,51,19,colors.blue)
  138. term.setBackgroundColor(colors.lightBlue)
  139. term.setCursorPos(3,3)
  140. print("Turn Front Output On Or Off?")
  141. local x1,y1 = 3,6
  142. local x2,y2 = 3,8
  143. local x3,y3 = 3,10
  144. local choice1 = " On "
  145. local choice2 = " Off "
  146. local choice3 = " Exit "
  147. term.setBackgroundColor(colors.red)
  148. term.setCursorPos(x1,y1)
  149. write(choice1)
  150. term.setCursorPos(x2,y2)
  151. write(choice2)
  152. term.setCursorPos(x3,y3)
  153. write(choice3)
  154. while true do
  155. local event, button, cx, cy = os.pullEvent()
  156. if event == "mouse_click" then
  157. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  158. redstone.setOutput("front",true)
  159. f = fs.open(frontf,"w")
  160. f.write("1")
  161. f.close()
  162. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  163. break
  164. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  165. redstone.setOutput("front",false)
  166. f = fs.open(frontf,"w")
  167. f.write("0")
  168. f.close()
  169. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  170. break
  171. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  172. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  173. break
  174. end
  175. end
  176. end
  177. end
  178. end
  179. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  180. break
  181. else if cx > x4 and cx < x4 + choice4:len() and cy == y4 and button == 1 then
  182. term.clear()
  183. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  184. paintutils.drawBox(1,1,51,19,colors.blue)
  185. term.setBackgroundColor(colors.lightBlue)
  186. term.setCursorPos(3,3)
  187. print("Turn Back Output On Or Off?")
  188. local x1,y1 = 3,6
  189. local x2,y2 = 3,8
  190. local x3,y3 = 3,10
  191. local choice1 = " On "
  192. local choice2 = " Off "
  193. local choice3 = " Exit "
  194. term.setBackgroundColor(colors.red)
  195. term.setCursorPos(x1,y1)
  196. write(choice1)
  197. term.setCursorPos(x2,y2)
  198. write(choice2)
  199. term.setCursorPos(x3,y3)
  200. write(choice3)
  201. while true do
  202. local event, button, cx, cy = os.pullEvent()
  203. if event == "mouse_click" then
  204. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  205. redstone.setOutput("back",true)
  206. f = fs.open(backf,"w")
  207. f.write("1")
  208. f.close()
  209. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  210. break
  211. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  212. redstone.setOutput("back",false)
  213. f = fs.open(backf,"w")
  214. f.write("0")
  215. f.close()
  216. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  217. break
  218. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  219. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  220. break
  221. end
  222. end
  223. end
  224. end
  225. end
  226. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  227. break
  228. else if cx > x5 and cx < x5 + choice5:len() and cy == y5 and button == 1 then
  229. term.clear()
  230. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  231. paintutils.drawBox(1,1,51,19,colors.blue)
  232. term.setBackgroundColor(colors.lightBlue)
  233. term.setCursorPos(3,3)
  234. print("Turn Top Output On Or Off?")
  235. local x1,y1 = 3,6
  236. local x2,y2 = 3,8
  237. local x3,y3 = 3,10
  238. local choice1 = " On "
  239. local choice2 = " Off "
  240. local choice3 = " Exit "
  241. term.setBackgroundColor(colors.red)
  242. term.setCursorPos(x1,y1)
  243. write(choice1)
  244. term.setCursorPos(x2,y2)
  245. write(choice2)
  246. term.setCursorPos(x3,y3)
  247. write(choice3)
  248. while true do
  249. local event, button, cx, cy = os.pullEvent()
  250. if event == "mouse_click" then
  251. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  252. redstone.setOutput("top",true)
  253. f = fs.open(topf,"w")
  254. f.write("1")
  255. f.close()
  256. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  257. break
  258. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  259. redstone.setOutput("top",false)
  260. f = fs.open(topf,"w")
  261. f.write("0")
  262. f.close()
  263. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  264. break
  265. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  266. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  267. break
  268. end
  269. end
  270. end
  271. end
  272. end
  273. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  274. break
  275. else if cx > x6 and cx < x6 + choice6:len() and cy == y6 and button == 1 then
  276. term.clear()
  277. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  278. paintutils.drawBox(1,1,51,19,colors.blue)
  279. term.setBackgroundColor(colors.lightBlue)
  280. term.setCursorPos(3,3)
  281. print("Turn Bottom Output On Or Off?")
  282. local x1,y1 = 3,6
  283. local x2,y2 = 3,8
  284. local x3,y3 = 3,10
  285. local choice1 = " On "
  286. local choice2 = " Off "
  287. local choice3 = " Exit "
  288. term.setBackgroundColor(colors.red)
  289. term.setCursorPos(x1,y1)
  290. write(choice1)
  291. term.setCursorPos(x2,y2)
  292. write(choice2)
  293. term.setCursorPos(x3,y3)
  294. write(choice3)
  295. while true do
  296. local event, button, cx, cy = os.pullEvent()
  297. if event == "mouse_click" then
  298. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  299. redstone.setOutput("bottom",true)
  300. f = fs.open(bottomf,"w")
  301. f.write("1")
  302. f.close()
  303. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  304. break
  305. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  306. redstone.setOutput("bottom",false)
  307. f = fs.open(bottomf,"w")
  308. f.write("0")
  309. f.close()
  310. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  311. break
  312. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  313. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  314. break
  315. end
  316. end
  317. end
  318. end
  319. end
  320. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  321. break
  322. else if cx > x7 and cx < x7 + choice7:len() and cy == y7 and button == 1 then
  323. ram(leftf,rightf,frontf,backf,topf,bottomf)
  324. break
  325. end
  326. end
  327. end
  328. end
  329. end
  330. end
  331. end
  332. end
  333. end
  334. end
  335. function cocr(leftf,rightf,frontf,backf,topf,bottomf)
  336. term.clear()
  337. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  338. paintutils.drawBox(1,1,51,19,colors.blue)
  339. term.setBackgroundColor(colors.lightBlue)
  340. term.setCursorPos(3,3)
  341. print("Enter a computer ID to control")
  342. term.setCursorPos(3,6)
  343. print("ID:")
  344. term.setCursorPos(6,6)
  345. sed = read()
  346. rednet.open("top")
  347. rednet.send(tonumber(sed),"cr")
  348. local senderid, message, protocol = rednet.receive(10)
  349. rednet.close("top")
  350. if message == nil then
  351. term.clear()
  352. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  353. paintutils.drawBox(1,1,51,19,colors.blue)
  354. term.setCursorPos(3,3)
  355. print("No response")
  356. term.setCursorPos(3,5)
  357. print("The target computer either isnt running red alert server or doesnt exist")
  358. sleep(5)
  359. ram(leftf,rightf,frontf,backf,topf,bottomf)
  360. end
  361. if message == "n" then
  362. term.clear()
  363. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  364. paintutils.drawBox(1,1,51,19,colors.blue)
  365. term.setCursorPos(3,3)
  366. print("Request denied")
  367. term.setCursorPos(3,5)
  368. print("The target computer denied your request, it may be already taking a request")
  369. sleep(5)
  370. ram(leftf,rightf,frontf,backf,topf,bottomf)
  371. end
  372. term.clear()
  373. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  374. paintutils.drawBox(1,1,51,19,colors.blue)
  375. term.setCursorPos(3,3)
  376. print("Control "..sed.."'s output")
  377. local x1,y1 = 3,5
  378. local x2,y2 = 3,7
  379. local x3,y3 = 3,9
  380. local x4,y4 = 3,11
  381. local x5,y5 = 3,13
  382. local x6,y6 = 3,15
  383. local x7,y7 = 3,17
  384. local choice1 = " Left "
  385. local choice2 = " Right "
  386. local choice3 = " Front "
  387. local choice4 = " Back "
  388. local choice5 = " Top "
  389. local choice6 = " Bottom "
  390. local choice7 = " Exit "
  391. term.setBackgroundColor(colors.red)
  392. term.setCursorPos(x1,y1)
  393. write(choice1)
  394. term.setCursorPos(x2,y2)
  395. write(choice2)
  396. term.setCursorPos(x3,y3)
  397. write(choice3)
  398. term.setCursorPos(x4,y4)
  399. write(choice4)
  400. term.setCursorPos(x5,y5)
  401. write(choice5)
  402. term.setCursorPos(x6,y6)
  403. write(choice6)
  404. term.setCursorPos(x7,y7)
  405. write(choice7)
  406. while true do
  407. local event, button, cx, cy = os.pullEvent()
  408. if event == "mouse_click" then
  409. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  410. term.clear()
  411. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  412. paintutils.drawBox(1,1,51,19,colors.blue)
  413. term.setBackgroundColor(colors.lightBlue)
  414. term.setCursorPos(3,3)
  415. print("Turn Left Output On Or Off?")
  416. local x1,y1 = 3,6
  417. local x2,y2 = 3,8
  418. local x3,y3 = 3,10
  419. local choice1 = " On "
  420. local choice2 = " Off "
  421. local choice3 = " Exit "
  422. term.setBackgroundColor(colors.red)
  423. term.setCursorPos(x1,y1)
  424. write(choice1)
  425. term.setCursorPos(x2,y2)
  426. write(choice2)
  427. term.setCursorPos(x3,y3)
  428. write(choice3)
  429. while true do
  430. local event, button, cx, cy = os.pullEvent()
  431. if event == "mouse_click" then
  432. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  433. rednet.open("top")
  434. rednet.send(tonumber(sed),"lon")
  435. rednet.close("top")
  436. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  437. break
  438. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  439. rednet.open("top")
  440. rednet.send(tonumber(sed),"loff")
  441. rednet.close("top")
  442. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  443. break
  444. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  445. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  446. break
  447. end
  448. end
  449. end
  450. end
  451. end
  452. break
  453. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  454. term.clear()
  455. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  456. paintutils.drawBox(1,1,51,19,colors.blue)
  457. term.setBackgroundColor(colors.lightBlue)
  458. term.setCursorPos(3,3)
  459. print("Turn Right Output On Or Off?")
  460. local x1,y1 = 3,6
  461. local x2,y2 = 3,8
  462. local x3,y3 = 3,10
  463. local choice1 = " On "
  464. local choice2 = " Off "
  465. local choice3 = " Exit "
  466. term.setBackgroundColor(colors.red)
  467. term.setCursorPos(x1,y1)
  468. write(choice1)
  469. term.setCursorPos(x2,y2)
  470. write(choice2)
  471. term.setCursorPos(x3,y3)
  472. write(choice3)
  473. while true do
  474. local event, button, cx, cy = os.pullEvent()
  475. if event == "mouse_click" then
  476. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  477. rednet.open("top")
  478. rednet.send(tonumber(sed),"ron")
  479. rednet.close("top")
  480. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  481. break
  482. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  483. rednet.open("top")
  484. rednet.send(tonumber(sed),"roff")
  485. rednet.close("top")
  486. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  487. break
  488. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  489. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  490. break
  491. end
  492. end
  493. end
  494. end
  495. end
  496. break
  497. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  498. term.clear()
  499. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  500. paintutils.drawBox(1,1,51,19,colors.blue)
  501. term.setBackgroundColor(colors.lightBlue)
  502. term.setCursorPos(3,3)
  503. print("Turn Front Output On Or Off?")
  504. local x1,y1 = 3,6
  505. local x2,y2 = 3,8
  506. local x3,y3 = 3,10
  507. local choice1 = " On "
  508. local choice2 = " Off "
  509. local choice3 = " Exit "
  510. term.setBackgroundColor(colors.red)
  511. term.setCursorPos(x1,y1)
  512. write(choice1)
  513. term.setCursorPos(x2,y2)
  514. write(choice2)
  515. term.setCursorPos(x3,y3)
  516. write(choice3)
  517. while true do
  518. local event, button, cx, cy = os.pullEvent()
  519. if event == "mouse_click" then
  520. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  521. rednet.open("top")
  522. rednet.send(tonumber(sed),"fon")
  523. rednet.close("top")
  524. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  525. break
  526. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  527. rednet.open("top")
  528. rednet.send(tonumber(sed),"foff")
  529. rednet.close("top")
  530. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  531. break
  532. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  533. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  534. break
  535. end
  536. end
  537. end
  538. end
  539. end
  540. break
  541. else if cx > x4 and cx < x4 + choice4:len() and cy == y4 and button == 1 then
  542. term.clear()
  543. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  544. paintutils.drawBox(1,1,51,19,colors.blue)
  545. term.setBackgroundColor(colors.lightBlue)
  546. term.setCursorPos(3,3)
  547. print("Turn Back Output On Or Off?")
  548. local x1,y1 = 3,6
  549. local x2,y2 = 3,8
  550. local x3,y3 = 3,10
  551. local choice1 = " On "
  552. local choice2 = " Off "
  553. local choice3 = " Exit "
  554. term.setBackgroundColor(colors.red)
  555. term.setCursorPos(x1,y1)
  556. write(choice1)
  557. term.setCursorPos(x2,y2)
  558. write(choice2)
  559. term.setCursorPos(x3,y3)
  560. write(choice3)
  561. while true do
  562. local event, button, cx, cy = os.pullEvent()
  563. if event == "mouse_click" then
  564. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  565. rednet.open("top")
  566. rednet.send(tonumber(sed),"baon")
  567. rednet.close("top")
  568. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  569. break
  570. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  571. rednet.open("top")
  572. rednet.send(tonumber(sed),"baoff")
  573. rednet.close("top")
  574. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  575. break
  576. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  577. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  578. break
  579. end
  580. end
  581. end
  582. end
  583. end
  584. break
  585. else if cx > x5 and cx < x5 + choice5:len() and cy == y5 and button == 1 then
  586. term.clear()
  587. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  588. paintutils.drawBox(1,1,51,19,colors.blue)
  589. term.setBackgroundColor(colors.lightBlue)
  590. term.setCursorPos(3,3)
  591. print("Turn Top Output On Or Off?")
  592. local x1,y1 = 3,6
  593. local x2,y2 = 3,8
  594. local x3,y3 = 3,10
  595. local choice1 = " On "
  596. local choice2 = " Off "
  597. local choice3 = " Exit "
  598. term.setBackgroundColor(colors.red)
  599. term.setCursorPos(x1,y1)
  600. write(choice1)
  601. term.setCursorPos(x2,y2)
  602. write(choice2)
  603. term.setCursorPos(x3,y3)
  604. write(choice3)
  605. while true do
  606. local event, button, cx, cy = os.pullEvent()
  607. if event == "mouse_click" then
  608. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  609. rednet.open("top")
  610. rednet.send(tonumber(sed),"ton")
  611. rednet.close("top")
  612. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  613. break
  614. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  615. rednet.open("top")
  616. rednet.send(tonumber(sed),"toff")
  617. rednet.close("top")
  618. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  619. break
  620. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  621. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  622. break
  623. end
  624. end
  625. end
  626. end
  627. end
  628. break
  629. else if cx > x6 and cx < x6 + choice6:len() and cy == y6 and button == 1 then
  630. term.clear()
  631. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  632. paintutils.drawBox(1,1,51,19,colors.blue)
  633. term.setBackgroundColor(colors.lightBlue)
  634. term.setCursorPos(3,3)
  635. print("Turn Bottom Output On Or Off?")
  636. local x1,y1 = 3,6
  637. local x2,y2 = 3,8
  638. local x3,y3 = 3,10
  639. local choice1 = " On "
  640. local choice2 = " Off "
  641. local choice3 = " Exit "
  642. term.setBackgroundColor(colors.red)
  643. term.setCursorPos(x1,y1)
  644. write(choice1)
  645. term.setCursorPos(x2,y2)
  646. write(choice2)
  647. term.setCursorPos(x3,y3)
  648. write(choice3)
  649. while true do
  650. local event, button, cx, cy = os.pullEvent()
  651. if event == "mouse_click" then
  652. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  653. rednet.open("top")
  654. rednet.send(tonumber(sed),"boon")
  655. rednet.close("top")
  656. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  657. break
  658. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  659. rednet.open("top")
  660. rednet.send(tonumber(sed),"boff")
  661. rednet.close("top")
  662. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  663. break
  664. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  665. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  666. break
  667. end
  668. end
  669. end
  670. end
  671. end
  672. break
  673. else if cx > x7 and cx < x7 + choice7:len() and cy == y7 and button == 1 then
  674. rednet.send(tonumber(sedt),"ce")
  675. ram(leftf,rightf,frontf,backf,topf,bottomf)
  676. break
  677. end
  678. end
  679. end
  680. end
  681. end
  682. end
  683. end
  684. end
  685. end
  686. end
  687. function rs(leftf,rightf,frontf,backf,topf,bottomf)
  688. term.clear()
  689. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  690. paintutils.drawBox(1,1,51,19,colors.blue)
  691. term.setBackgroundColor(colors.lightBlue)
  692. term.setCursorPos(3,3)
  693. print("Red Alert Settings")
  694. local x1,y1 = 3,5
  695. local x2,y2 = 3,7
  696. local choice1 = " Change Directory "
  697. local choice2 = " Exit "
  698. term.setBackgroundColor(colors.red)
  699. term.setCursorPos(x1,y1)
  700. write(choice1)
  701. term.setCursorPos(x2,y2)
  702. write(choice2)
  703. while true do
  704. local event, button, cx, cy = os.pullEvent()
  705. if event == "mouse_click" then
  706. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  707. term.clear()
  708. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  709. paintutils.drawBox(1,1,51,19,colors.blue)
  710. term.setBackgroundColor(colors.lightBlue)
  711. term.setCursorPos(3,3)
  712. print("Enter a directory")
  713. term.setCursorPos(3,5)
  714. print("Directory:")
  715. term.setCursorPos(13,5)
  716. nd = read()
  717. if not fs.exists(nd) then
  718. term.setCursorPos(3,7)
  719. print("Directory doesnt exist")
  720. sleep(3)
  721. rs(leftf,rightf,frontf,backf,topf,bottomf)
  722. break
  723. end
  724. f = fs.open("/RAD","w")
  725. f.write(nd)
  726. f.close()
  727. ram(leftf,rightf,frontf,backf,topf,bottomf)
  728. break
  729. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  730. ram(leftf,rightf,frontf,backf,topf,bottomf)
  731. break
  732. end
  733. end
  734. end
  735. end
  736. end
  737. function stcr(leftf,rightf,frontf,backf,topf,bottomf)
  738. term.clear()
  739. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  740. paintutils.drawBox(1,1,51,19,colors.blue)
  741. term.setBackgroundColor(colors.lightBlue)
  742. f1 = fs.open(leftf,"r")
  743. f2 = fs.open(rightf,"r")
  744. f3 = fs.open(frontf,"r")
  745. f4 = fs.open(backf,"r")
  746. f5 = fs.open(topf,"r")
  747. f6 = fs.open(bottomf,"r")
  748. leftc = f1.readAll()
  749. rightc = f2.readAll()
  750. frontc = f3.readAll()
  751. backc = f4.readAll()
  752. topc = f5.readAll()
  753. bottomc = f6.readAll()
  754. f1.close()
  755. f2.close()
  756. f3.close()
  757. f4.close()
  758. f5.close()
  759. f6.close()
  760. if leftc == "0" then
  761. leftc = "no"
  762. else if leftc == "1" then
  763. leftc = "yes"
  764. end
  765. end
  766. if rightc == "0" then
  767. rightc = "no"
  768. else if rightc == "1" then
  769. rightc = "yes"
  770. end
  771. end
  772. if frontc == "0" then
  773. frontc = "no"
  774. else if frontc == "1" then
  775. frontc = "yes"
  776. end
  777. end
  778. if backc == "0" then
  779. backc = "no"
  780. else if backc == "1" then
  781. backc = "yes"
  782. end
  783. end
  784. if topc == "0" then
  785. topc = "no"
  786. else if topc == "1" then
  787. topc = "yes"
  788. end
  789. end
  790. if bottomc == "0" then
  791. bottomc = "no"
  792. else if bottomc == "1" then
  793. bottomc = "yes"
  794. end
  795. end
  796. term.setCursorPos(3,3)
  797. print("Left : "..leftc)
  798. term.setCursorPos(3,5)
  799. print("Right : "..rightc)
  800. term.setCursorPos(3,7)
  801. print("Front : "..frontc)
  802. term.setCursorPos(3,9)
  803. print("Back : "..backc)
  804. term.setCursorPos(3,11)
  805. print("Top : "..topc)
  806. term.setCursorPos(3,13)
  807. print("Bottom : "..bottomc)
  808. sleep(5)
  809. ram(leftf,rightf,frontf,backf,topf,bottomf)
  810. end
  811. function socr(leftf,rightf,frontf,backf,topf,bottomf)
  812. term.clear()
  813. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  814. paintutils.drawBox(1,1,51,19,colors.blue)
  815. term.setBackgroundColor(colors.lightBlue)
  816. term.setCursorPos(3,3)
  817. print("Enter an ID to check")
  818. term.setCursorPos(3,5)
  819. print("ID:")
  820. term.setCursorPos(6,5)
  821. sed = tonumber(read())
  822. rednet.open("top")
  823. rednet.send(sed,"rc")
  824. local senderId, msg1, protocol = rednet.receive(10)
  825. local senderId, msg2, protocol = rednet.receive(10)
  826. local senderId, msg3, protocol = rednet.receive(10)
  827. local senderId, msg4, protocol = rednet.receive(10)
  828. local senderId, msg5, protocol = rednet.receive(10)
  829. local senderId, msg6, protocol = rednet.receive(10)
  830. if msg1 == nil then
  831. term.setCursorPos(3,8)
  832. print("No Response")
  833. term.setCursorPos(3,10)
  834. print("Target computer may not be running red alert server or may not exist")
  835. end
  836. term.clear()
  837. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  838. paintutils.drawBox(1,1,51,19,colors.blue)
  839. term.setBackgroundColor(colors.lightBlue)
  840. term.setCursorPos(3,3)
  841. print("Left : "..msg1)
  842. print("Right : "..msg2)
  843. print("Front : "..msg3)
  844. print("Back : "..msg4)
  845. print("Top : "..msg5)
  846. print("Bottom : "..msg6)
  847. sleep(5)
  848. ram(leftf,rightf,frontf,backf,topf,bottomf)
  849. end
  850. function ram(leftf,rightf,frontf,backf,topf,bottomf)
  851. term.clear()
  852. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  853. paintutils.drawBox(1,1,51,19,colors.blue)
  854. term.setTextColor(colors.white)
  855. term.setBackgroundColor(colors.lightBlue)
  856. term.setCursorPos(3,3)
  857. print("Red Alert Menu")
  858. local x1,y1 = 3,6
  859. local x2,y2 = 3,8
  860. local x3,y3 = 3,10
  861. local x4,y4 = 3,12
  862. local x5,y5 = 3,14
  863. local x6,y6 = 3,16
  864. local choice1 = " Control This Computer's Redstone "
  865. local choice2 = " Control Other Computer's Redstone "
  866. local choice3 = " Exit "
  867. local choice4 = " Settings "
  868. local choice5 = " Show This Computer's Active Redstone "
  869. local choice6 = " Show Other Computer's Active Redstone "
  870. term.setBackgroundColor(colors.red)
  871. term.setCursorPos(x1,y1)
  872. write(choice1)
  873. term.setCursorPos(x2,y2)
  874. write(choice2)
  875. term.setCursorPos(x3,y3)
  876. write(choice3)
  877. term.setCursorPos(x4,y4)
  878. write(choice4)
  879. term.setCursorPos(x5,y5)
  880. write(choice5)
  881. term.setCursorPos(x6,y6)
  882. write(choice6)
  883. while true do
  884. local event, button, cx, cy = os.pullEvent()
  885. if event == "mouse_click" then
  886. if cx > x1 and cx < x1 + choice1:len() and cy == y1 and button == 1 then
  887. ctcr(leftf,rightf,frontf,backf,topf,bottomf)
  888. break
  889. else if cx > x2 and cx < x2 + choice2:len() and cy == y2 and button == 1 then
  890. cocr(leftf,rightf,frontf,backf,topf,bottomf)
  891. break
  892. else if cx > x3 and cx < x3 + choice3:len() and cy == y3 and button == 1 then
  893. fs.delete(leftf)
  894. fs.delete(rightf)
  895. fs.delete(frontf)
  896. fs.delete(backf)
  897. fs.delete(topf)
  898. fs.delete(bottomf)
  899. break
  900. else if cx > x4 and cx < x4 + choice4:len() and cy == y4 and button == 1 then
  901. rs(leftf,rightf,frontf,backf,topf,bottomf)
  902. break
  903. else if cx > x5 and cx < x5 + choice5:len() and cy == y5 and button == 1 then
  904. stcr(leftf,rightf,frontf,backf,topf,bottomf)
  905. break
  906. else if cx > x6 and cx < x6 + choice6:len() and cy == y6 and button == 1 then
  907. socr(leftf,rightf,frontf,backf,topf,bottomf)
  908. break
  909. end
  910. end
  911. end
  912. end
  913. end
  914. end
  915. end
  916. end
  917. end
  918. function err(e)
  919. print("ERROR:"..e)
  920. print("Please report this error to the owner")
  921. sleep(5)
  922. end
  923. term.clear()
  924. term.setCursorPos(1,1)
  925. term.setTextColor(colors.red)
  926. print("Starting Red Alert")
  927. f = fs.open("/RAD","r")
  928. rad = f.readAll()
  929. f.close()
  930. print(rad)
  931. fs.makeDir(rad.."temp")
  932. radt = rad.."temp/"
  933. leftf = radt.."left"
  934. rightf = radt.."right"
  935. frontf = radt.."front"
  936. backf = radt.."back"
  937. topf = radt.."top"
  938. bottomf = radt.."bottom"
  939. print(leftf)
  940. print(rightf)
  941. print(frontf)
  942. print(backf)
  943. print(topf)
  944. print(bottomf)
  945. f1 = fs.open(leftf,"w")
  946. f2 = fs.open(rightf,"w")
  947. f3 = fs.open(frontf,"w")
  948. f4 = fs.open(backf,"w")
  949. f5 = fs.open(topf,"w")
  950. f6 = fs.open(bottomf,"w")
  951. f1.write("0")
  952. f2.write("0")
  953. f3.write("0")
  954. f4.write("0")
  955. f5.write("0")
  956. f6.write("0")
  957. f1.close()
  958. f2.close()
  959. f3.close()
  960. f4.close()
  961. f5.close()
  962. f6.close()
  963. f1 = fs.open(leftf,"r")
  964. f2 = fs.open(rightf,"r")
  965. f3 = fs.open(frontf,"r")
  966. f4 = fs.open(backf,"r")
  967. f5 = fs.open(topf,"r")
  968. f6 = fs.open(bottomf,"r")
  969. f1c = f1.readAll()
  970. f2c = f2.readAll()
  971. f3c = f3.readAll()
  972. f4c = f4.readAll()
  973. f5c = f5.readAll()
  974. f6c = f6.readAll()
  975. f1.close()
  976. f2.close()
  977. f3.close()
  978. f4.close()
  979. f5.close()
  980. f6.close()
  981. print(f1c)
  982. print(f2c)
  983. print(f3c)
  984. print(f4c)
  985. print(f5c)
  986. print(f6c)
  987. if not f1c == 0 then
  988. err("f1cn0")
  989. else if not f2c == 0 then
  990. err("f2cn0")
  991. else if not f3c == 0 then
  992. err("f3cn0")
  993. else if not f4c == 0 then
  994. err("f4cn0")
  995. else if not f5c == 0 then
  996. err("f5cn0")
  997. else if not f6c == 0 then
  998. err("f6cn0")
  999. end
  1000. end
  1001. end
  1002. end
  1003. end
  1004. end
  1005. print("Successfully started Red Alert 1.0")
  1006. sleep(5)
  1007. ram(leftf,rightf,frontf,backf,topf,bottomf)
Add Comment
Please, Sign In to add comment