Advertisement
craniumkid22

Master Control System 1.7.2 beta

Sep 5th, 2012
1,832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 75.25 KB | None | 0 0
  1. --Made by Craniumkid22
  2. --This code is free to use, under a few conditions:
  3. --1. DO NOT claim this as your own work!
  4. --2. If you change this code, feel free to contact me on the CC forums, user-Craniumkid22.
  5. --3. if you have questions about any of this code, feel free to contact me as well.
  6.  
  7. --CREDITS:
  8.  
  9. --Huge thanks to Lyqyd for pounding the necessity of local variables into my thick skull.
  10. --Major credit goes to Pharap for helping me squash bugs, and helping with the Slots program.
  11. --Thanks to MysticT for helping with the logging function. Helps me with bugs.
  12. --Thanks to PaymentOption/Grim Reaper for suggesting to break this atrociously long script into separate files.
  13. --
  14.  
  15. --debug notes--
  16. --add mass fabricator
  17. --remove redstone
  18.  
  19. -- variables
  20. local controlTable = {}
  21. local symbol = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}
  22. local menu = {
  23. "Production Control",
  24. "Reactor Control",
  25. "Lights",
  26. "Maintenance",
  27. "Games",
  28. "Shutdown"
  29. }
  30. local answers = {
  31. "It is Certain ",
  32. " Decidedly So ",
  33. "      No      ",
  34. "      Yes     ",
  35. "   No doubt   ",
  36. "     Never    ",
  37. "    Unknown   ",
  38. "  Ask again   ",
  39. "   Doubtful   ",
  40. " Most Likely  ",
  41. "Cannot predict",
  42. " Probably not ",
  43. " Stars say no ",
  44. "   For sure   "
  45. }
  46. local gMenu = {
  47. "Lucky Dice",
  48. "Magic 8 Block",
  49. "Card Slots",
  50. "Main Menu"
  51. }
  52. local mMenu = {
  53. "System Status",
  54. "Run initialization",
  55. "Return to Main menu"
  56. }
  57. local rMenu = {
  58. "Start Reactor",
  59. "Shutdown Reactor",
  60. "Return to Main menu"
  61. }
  62. local pMenu = {
  63. "Macerator",
  64. "Furnace",
  65. "Compressor",
  66. "Extractor",
  67. "RedPower Pump",
  68. "Blockbreaker Array",
  69. "Mining Well",
  70. "Quarry",
  71. "Buildcraft Pump",
  72. "Forcefield",
  73. "Return to Main menu"
  74. }
  75. local colorOpt={
  76. "Redstone/Red alloy wire",
  77. "White",
  78. "Orange",
  79. "Magenta",
  80. "Light Blue",
  81. "Yellow",
  82. "Lime",
  83. "Pink",
  84. "Gray",
  85. "Light Gray",
  86. "Cyan",
  87. "Purple",
  88. "Blue",
  89. "Brown",
  90. "Green",
  91. "Red",
  92. "Black"
  93. }
  94. local eType={
  95. "None",
  96. "BatBox",
  97. "MFE",
  98. "MFSU"
  99. }
  100. local IC2power={
  101. "None",
  102. "Generator",
  103. "Geothermal Generator",
  104. "Water Mill",
  105. "Wind Mill",
  106. "Solar Panel",
  107. "Nuclear Reactor"
  108. }
  109. local BCpower={
  110. "Redstone Engine",
  111. "Steam Engine",
  112. "Combustion Engine",
  113. "Electric Engine"
  114. }
  115. local pTypeX={
  116. "RedstoneEngine",
  117. "SteamEngine",
  118. "CombustionEngine",
  119. "ElectricEngine"
  120. }
  121. local sSide = {
  122. "left",
  123. "right",
  124. "top",
  125. "bottom",
  126. "back",
  127. "front"
  128. }
  129. local modslist = {
  130. "IndustrialCraft 2",
  131. "RedPower 2",
  132. "Buildcraft",
  133. "Immibis' Forcefields"
  134. }
  135. local machineList = {
  136. "Lights",
  137. "RedstoneEngine",
  138. "SteamEngine",
  139. "CombustionEngine",
  140. "ElectricEngine",
  141. "Reactor",
  142. "Coolant",
  143. "Macerator",
  144. "Furnace",
  145. "Compressor",
  146. "Extractor",
  147. "RedPowerPump",
  148. "BlockbreakerArray",
  149. "MiningWell",
  150. "Quarry",
  151. "BuildcraftPump",
  152. "Forcefield"
  153. }
  154.  
  155.  
  156.  
  157.  
  158. --peripheral check
  159. for i=1,#sSide do
  160. if peripheral.isPresent(sSide[i]) then
  161.     if peripheral.getType(sSide[i]) == "monitor" then mon = peripheral.wrap(sSide[i]) pM = true
  162.     elseif peripheral.getType(sSide[i]) == "disk" then disk = sSide pD = true
  163.     elseif peripheral.getType(sSide[i]) == "modem" then modem = sSide pW = true
  164.     elseif peripheral.getType(sSide[i])==nil then
  165.         error("fail")
  166.         local mon=term
  167.     end
  168. end
  169. end
  170. --option function
  171. local function opt(m,mY)
  172. n=1
  173. l=#m
  174. while true do
  175.     for i=1, l, 1 do
  176.     if i==n then
  177.     local x, y = term.getSize()
  178.     local b = string.len(">"..m[i].."<")/2
  179.     local x = (x/2)-b
  180.     term.setCursorPos(x,i+mY)
  181.     term.clearLine()
  182.     print(">"..m[i].."<")
  183.     else
  184.     local x, y = term.getSize()
  185.     b = string.len(m[i])/2
  186.     x = (x/2)-b
  187.     term.setCursorPos(x,i+mY)
  188.     term.clearLine()
  189.     print(m[i]) end
  190.     end
  191. a, b= os.pullEventRaw()
  192. if a == "key" then
  193. if b==200 and n>1 then n=n-1 end
  194. if b==208 and n<l then n=n+1 end
  195. if b==28 then break end
  196. end
  197. end
  198. term.clear() term.setCursorPos(1,1)
  199. return n
  200. end
  201. -- screen functions
  202. local function title()
  203. term.clear()
  204. term.setCursorPos(1,1)
  205. print("     Welcome to Master Control initialization!")
  206. print("       Please read each selection carefully.")
  207. print("          If you mess up, press CTRL + T")
  208. print("             And run the wizard again.")
  209. term.setCursorPos(1,9)
  210. end
  211. local function newPage()
  212. term.clear()
  213. term.setCursorPos(1,1)
  214. print(".-----------------------------------------------.")
  215. print("|           Welcome to Master Control           |")
  216. print("|                    Ver. 1.7                   |")
  217. print("+-----------------------------------------------+")
  218. term.setCursorPos(1,6)
  219. print("          Please select Program to run")
  220. term.setCursorPos(1,8)
  221. end
  222. local function nukePage()
  223. term.clear()
  224. term.setCursorPos(1,1)
  225. print(".-----------------------------------------------.")
  226. print("|               Welcome to NukeOS               |")
  227. print("|                   Ver. 1.7                    |")
  228. print("+-----------------------------------------------+")
  229. term.setCursorPos(1,5)
  230. end
  231. local function prodPage()
  232. term.clear()
  233. term.setCursorPos(1,1)
  234. print(".-----------------------------------------------.")
  235. print("|              Production Control               |")
  236. print("|                   Ver. 1.7                    |")
  237. print("+-----------------------------------------------+")
  238. term.setCursorPos(1,6)
  239. end
  240. local function mainPage()
  241. term.clear()
  242. term.setCursorPos(1,1)
  243. print(".-----------------------------------------------.")
  244. print("|               Maintenance Access              |")
  245. print("+-----------------------------------------------+")
  246. term.setCursorPos(1,6)
  247. print("              Please Select Function             ")
  248. term.setCursorPos(1,8)
  249. end
  250. local function blank()
  251. term.setCursorPos(7,3)
  252. print("+--------------+  +--------------+")
  253. term.setCursorPos(7,4)
  254. print("|              |  |              |")
  255. term.setCursorPos(7,5)
  256. print("|              |  |              |")
  257. term.setCursorPos(7,6)
  258. print("| Press ENTER  |  |   to  Roll   |")
  259. term.setCursorPos(7,7)
  260. print("|              |  |              |")
  261. term.setCursorPos(7,8)
  262. print("|  BACKSPACE   |  |   to  Exit   |")
  263. term.setCursorPos(7,9)
  264. print("|              |  |              |")
  265. term.setCursorPos(7,10)
  266. print("|              |  |              |")
  267. term.setCursorPos(7,11)
  268. print("+--------------+  +--------------+")
  269. end
  270. local function gPage()
  271. term.clear()
  272. term.setCursorPos(1,1)
  273. print("    _______  _______  _______  _______  _______ ")
  274. print("   (  ____ \\(  ___  )(       )(  ____ \\(  ____ \\")
  275. print("   | (    \\/| (   ) || () () || (    \\/| (    \\/")
  276. print("   | |      | (___) || || || || (__    | (_____ ")
  277. print("   | | ____ |  ___  || |(_)| ||  __)   (_____  )")
  278. print("   | | \\_  )| (   ) || |   | || (            ) |")
  279. print("   | (___) || )   ( || )   ( || (____/\\/\\____) |")
  280. print("   (_______)|/     \\||/     \\|(_______/\\_______)")
  281. end
  282. local function sTitle()
  283. term.setCursorPos(1,15)
  284. print("   __    __   ___  ___    __  _    ___ _____ __ ")
  285. print("  / /'  / /\\ | |_)| | \\  ( ('| |  / / \\ | | ( ('")
  286. print("  \\_\\_,/_/--\\|_| \\|_|_/  _)_)|_|__\\_\\_/ |_| _)_)")
  287. end
  288. local function loser()
  289. term.clear()
  290. term.setCursorPos(1,5)
  291. print("          __      ___    __   ____ ____ ")
  292. print("          ||     // \\\\  (( \\ ||    || \\\\")
  293. print("          ||    ((   ))  \\\\  ||==  ||_//")
  294. print("          ||__|  \\\\_//  \\_)) ||___ || \\\\")
  295. sleep(3)
  296. term.clear()
  297. end
  298. local function jackpot()
  299. for x = 1,5 do
  300. term.clear()
  301. sleep(.25)
  302. term.setCursorPos(1,5)
  303. print("     __  ___    ___ __ __ ____    ___   ______")
  304. print("     || // \\\\  //   || // || \\\\  // \\\\  | || |")
  305. print("     || ||=|| ((    ||<<  ||_// ((   ))   ||  ")
  306. print("  |__|| || ||  \\\\__ || \\\\ ||     \\\\_//    ||  ")
  307. sleep(.25)
  308. end
  309. end
  310. local function soon()
  311. for i = 1,5 do
  312. term.clear()
  313. term.setCursorPos(1,1)
  314. sleep(.25)
  315. print("                )         (       )         ")
  316. print("          (  ( /(  (      )\\ ) ( /( (       ")
  317. print("          )\\ )\\()) )\\))( (()/( )\\()))\\ )    ")
  318. print("        (((_|(_)\\ ((_)()\\ /(_)|(_)\\(()/(    ")
  319. print("        )\\___ ((_)(_()((_|_))  _((_)/(_))_  ")
  320. print("       ((/ __/ _ \\|  \\/  |_ _|| \\| (_)) __| ")
  321. print("        | (_| (_) | |\\/| || | | .' | | (_ | ")
  322. print("        (\\___\\__)/|_|  |_|__)||_|\\_|  \\___| ")
  323. print("                                            ")
  324. print("               )\\ ) ( /(  ( /(  ( /(        ")
  325. print("              (()/( )\\()) )\\()) )\\())       ")
  326. print("               /(_)|(_)\\ ((_)\\ ((_)\\        ")
  327. print("              (_))   ((_)  ((_) _((_)       ")
  328. print("              / __| / _ \\ / _ \\| \\| |       ")
  329. print("              \\__ \\| (_) | (_) | .' |       ")
  330. print("              |___/ \\___/ \\___/|_|\\_|       ")
  331. sleep(.5)
  332. end
  333. end
  334.     -- dice functions
  335. local function dTitle()
  336. term.setCursorPos(1,14)
  337. print("      __            __          ___  _        ")
  338. print("     / /  __ ______/ /____ __  / _ \\(_)______ ")
  339. print("    / /__/ // / __/  '_/ // / / // / / __/ -_)")
  340. print("   /____/\\_,_/\\__/_/\\_\\\\_, / /____/_/\\__/\\__/ ")
  341. print("                      /___/                   ")
  342. end
  343. local function die1()
  344. local x = math.random(1,6)
  345. if x == 1 then
  346. term.setCursorPos(7,3)
  347. print("+--------------+")
  348. term.setCursorPos(7,4)
  349. print("|              |")
  350. term.setCursorPos(7,5)
  351. print("|              |")
  352. term.setCursorPos(7,6)
  353. print("|              |")
  354. term.setCursorPos(7,7)
  355. print("|      O       |")
  356. term.setCursorPos(7,8)
  357. print("|              |")
  358. term.setCursorPos(7,9)
  359. print("|              |")
  360. term.setCursorPos(7,10)
  361. print("|              |")
  362. term.setCursorPos(7,11)
  363. print("+--------------+")
  364. elseif x == 2 then
  365. term.setCursorPos(7,3)
  366. print("+--------------+")
  367. term.setCursorPos(7,4)
  368. print("|              |")
  369. term.setCursorPos(7,5)
  370. print("|          O   |")
  371. term.setCursorPos(7,6)
  372. print("|              |")
  373. term.setCursorPos(7,7)
  374. print("|              |")
  375. term.setCursorPos(7,8)
  376. print("|              |")
  377. term.setCursorPos(7,9)
  378. print("|  O           |")
  379. term.setCursorPos(7,10)
  380. print("|              |")
  381. term.setCursorPos(7,11)
  382. print("+--------------+")
  383. elseif x == 3 then
  384. term.setCursorPos(7,3)
  385. print("+--------------+")
  386. term.setCursorPos(7,4)
  387. print("|              |")
  388. term.setCursorPos(7,5)
  389. print("|          O   |")
  390. term.setCursorPos(7,6)
  391. print("|              |")
  392. term.setCursorPos(7,7)
  393. print("|      O       |")
  394. term.setCursorPos(7,8)
  395. print("|              |")
  396. term.setCursorPos(7,9)
  397. print("|  O           |")
  398. term.setCursorPos(7,10)
  399. print("|              |")
  400. term.setCursorPos(7,11)
  401. print("+--------------+")
  402. elseif x == 4 then
  403. term.setCursorPos(7,3)
  404. print("+--------------+")
  405. term.setCursorPos(7,4)
  406. print("|              |")
  407. term.setCursorPos(7,5)
  408. print("|  O       O   |")
  409. term.setCursorPos(7,6)
  410. print("|              |")
  411. term.setCursorPos(7,7)
  412. print("|              |")
  413. term.setCursorPos(7,8)
  414. print("|              |")
  415. term.setCursorPos(7,9)
  416. print("|  O       O   |")
  417. term.setCursorPos(7,10)
  418. print("|              |")
  419. term.setCursorPos(7,11)
  420. print("+--------------+")
  421. elseif x == 5 then
  422. term.setCursorPos(7,3)
  423. print("+--------------+")
  424. term.setCursorPos(7,4)
  425. print("|              |")
  426. term.setCursorPos(7,5)
  427. print("|  O       O   |")
  428. term.setCursorPos(7,6)
  429. print("|              |")
  430. term.setCursorPos(7,7)
  431. print("|      O       |")
  432. term.setCursorPos(7,8)
  433. print("|              |")
  434. term.setCursorPos(7,9)
  435. print("|  O       O   |")
  436. term.setCursorPos(7,10)
  437. print("|              |")
  438. term.setCursorPos(7,11)
  439. print("+--------------+")
  440. elseif x == 6 then
  441. term.setCursorPos(7,3)
  442. print("+--------------+")
  443. term.setCursorPos(7,4)
  444. print("|              |")
  445. term.setCursorPos(7,5)
  446. print("|  O       O   |")
  447. term.setCursorPos(7,6)
  448. print("|              |")
  449. term.setCursorPos(7,7)
  450. print("|  O       O   |")
  451. term.setCursorPos(7,8)
  452. print("|              |")
  453. term.setCursorPos(7,9)
  454. print("|  O       O   |")
  455. term.setCursorPos(7,10)
  456. print("|              |")
  457. term.setCursorPos(7,11)
  458. print("+--------------+")
  459. end
  460. end
  461. local function die2()
  462. local x = math.random(1,6)
  463. if x == 1 then
  464. term.setCursorPos(25,3)
  465. print("+--------------+")
  466. term.setCursorPos(25,4)
  467. print("|              |")
  468. term.setCursorPos(25,5)
  469. print("|              |")
  470. term.setCursorPos(25,6)
  471. print("|              |")
  472. term.setCursorPos(25,7)
  473. print("|      O       |")
  474. term.setCursorPos(25,8)
  475. print("|              |")
  476. term.setCursorPos(25,9)
  477. print("|              |")
  478. term.setCursorPos(25,10)
  479. print("|              |")
  480. term.setCursorPos(25,11)
  481. print("+--------------+")
  482. elseif x == 2 then
  483. term.setCursorPos(25,3)
  484. print("+--------------+")
  485. term.setCursorPos(25,4)
  486. print("|              |")
  487. term.setCursorPos(25,5)
  488. print("|          O   |")
  489. term.setCursorPos(25,6)
  490. print("|              |")
  491. term.setCursorPos(25,7)
  492. print("|              |")
  493. term.setCursorPos(25,8)
  494. print("|              |")
  495. term.setCursorPos(25,9)
  496. print("|  O           |")
  497. term.setCursorPos(25,10)
  498. print("|              |")
  499. term.setCursorPos(25,11)
  500. print("+--------------+")
  501. elseif x == 3 then
  502. term.setCursorPos(25,3)
  503. print("+--------------+")
  504. term.setCursorPos(25,4)
  505. print("|              |")
  506. term.setCursorPos(25,5)
  507. print("|          O   |")
  508. term.setCursorPos(25,6)
  509. print("|              |")
  510. term.setCursorPos(25,7)
  511. print("|      O       |")
  512. term.setCursorPos(25,8)
  513. print("|              |")
  514. term.setCursorPos(25,9)
  515. print("|  O           |")
  516. term.setCursorPos(25,10)
  517. print("|              |")
  518. term.setCursorPos(25,11)
  519. print("+--------------+")
  520. elseif x == 4 then
  521. term.setCursorPos(25,3)
  522. print("+--------------+")
  523. term.setCursorPos(25,4)
  524. print("|              |")
  525. term.setCursorPos(25,5)
  526. print("|  O       O   |")
  527. term.setCursorPos(25,6)
  528. print("|              |")
  529. term.setCursorPos(25,7)
  530. print("|              |")
  531. term.setCursorPos(25,8)
  532. print("|              |")
  533. term.setCursorPos(25,9)
  534. print("|  O       O   |")
  535. term.setCursorPos(25,10)
  536. print("|              |")
  537. term.setCursorPos(25,11)
  538. print("+--------------+")
  539. elseif x == 5 then
  540. term.setCursorPos(25,3)
  541. print("+--------------+")
  542. term.setCursorPos(25,4)
  543. print("|              |")
  544. term.setCursorPos(25,5)
  545. print("|  O       O   |")
  546. term.setCursorPos(25,6)
  547. print("|              |")
  548. term.setCursorPos(25,7)
  549. print("|      O       |")
  550. term.setCursorPos(25,8)
  551. print("|              |")
  552. term.setCursorPos(25,9)
  553. print("|  O       O   |")
  554. term.setCursorPos(25,10)
  555. print("|              |")
  556. term.setCursorPos(25,11)
  557. print("+--------------+")
  558. elseif x == 6 then
  559. term.setCursorPos(25,3)
  560. print("+--------------+")
  561. term.setCursorPos(25,4)
  562. print("|              |")
  563. term.setCursorPos(25,5)
  564. print("|  O       O   |")
  565. term.setCursorPos(25,6)
  566. print("|              |")
  567. term.setCursorPos(25,7)
  568. print("|  O       O   |")
  569. term.setCursorPos(25,8)
  570. print("|              |")
  571. term.setCursorPos(25,9)
  572. print("|  O       O   |")
  573. term.setCursorPos(25,10)
  574. print("|              |")
  575. term.setCursorPos(25,11)
  576. print("+--------------+")
  577. end
  578. end
  579. local function roll()
  580. local r = 1
  581. for r = 1,50 do
  582. parallel.waitForAll(die1,die2,sleep(.1))
  583. end
  584. end
  585. local function dice()
  586. while true do
  587. term.clear()
  588. dTitle()
  589. blank()
  590. event, p1 = os.pullEvent("key")
  591.     if p1 == 28 then
  592.     roll()
  593.     sleep(3)
  594.     elseif p1 == 14 then break
  595.     end
  596. end
  597. end
  598.     -- 8block functions
  599. local function bTitle()
  600. term.clear()
  601. term.setCursorPos(1,1)
  602. print("  _ _ _                  __      __    _          ")
  603. print(" ' ) ) )                (  )    /  )  //       /  ")
  604. print("  / / / __.  _,  o _.   ./'    /--<  // __ _. /_  ")
  605. print(" / ' (_(_/|_(_)_<_(__  (__)   /___/_</_(_)(__/ <_ ")
  606. print("             /|                                   ")
  607. print("            |/                                    ")
  608. end
  609. local function ans()
  610. term.clear()
  611. bTitle()
  612. term.setCursorPos(1,7)
  613. print("                .----------------. ")
  614. print("               | .--------------. |")
  615. print("               | |              | |")
  616. print("               | |              | |")
  617. print("               | |              | |")
  618. print("               | |"..answers[math.random(1,#answers)].."| |")
  619. print("               | |              | |")
  620. print("               | |              | |")
  621. print("               | |              | |")
  622. print("               | '--------------' |")
  623. print("                '----------------' ")
  624. end
  625. local function start()
  626. bTitle()
  627. term.setCursorPos(1,7)
  628. print("                .----------------.                ")
  629. print("Ask me ANY     | .--------------. |               ")
  630. print("question, and  | |     ____     | |   BACKSPACE   ")
  631. print("press ENTER    | |   .' __ '.   | |               ")
  632. print("to receive     | |   | (__) |   | |               ")
  633. print("your answer... | |   .'____'.   | |    to exit    ")
  634. print("               | |  | (____) |  | |               ")
  635. print("               | |  '.______.'  | |               ")
  636. print("               | |              | |               ")
  637. print("               | '--------------' |               ")
  638. print("                '----------------'                ")
  639. end
  640. local function shake()
  641. term.clear()
  642. bTitle()
  643. term.setCursorPos(1,7)
  644. print("                 .----------------.               ")
  645. print("                | .--------------. |          *   ")
  646. print("            *   | |              | |              ")
  647. print("                | |              | |              ")
  648. print("   *            | |              | |  *           ")
  649. print("                | |              | |              ")
  650. print("                | |              | |              ")
  651. print("        *       | |              | |       *      ")
  652. print("                | |              | |              ")
  653. print("   *            | '--------------' |              ")
  654. print("                 '----------------'               ")
  655. sleep(.2)
  656. term.clear()
  657. bTitle()
  658. term.setCursorPos(1,7)
  659. print("  *            .----------------.                 ")
  660. print("              | .--------------. |                ")
  661. print("              | |              | |    *      *    ")
  662. print("       *      | |              | |                ")
  663. print("              | |              | |                ")
  664. print("              | |              | |                ")
  665. print("              | |              | |    *           ")
  666. print("              | |              | |                ")
  667. print("     *        | |              | |      *         ")
  668. print("              | '--------------' |                ")
  669. print("               '----------------'                 ")
  670. sleep(.2)
  671. term.clear()
  672. bTitle()
  673. term.setCursorPos(1,7)
  674. print("                .----------------.                ")
  675. print("     *         | .--------------. | *             ")
  676. print("               | |              | |               ")
  677. print("               | |              | |               ")
  678. print("      *        | |              | |               ")
  679. print("               | |              | |       *       ")
  680. print("               | |              | |               ")
  681. print("   *           | |              | |               ")
  682. print("               | |              | |            *  ")
  683. print("             * | '--------------' |     *         ")
  684. print("                '----------------'                ")
  685. sleep(.2)
  686. term.clear()
  687. bTitle()
  688. term.setCursorPos(1,7)
  689. print("                 .----------------.               ")
  690. print("          *     | .--------------. |          *   ")
  691. print("                | |              | |              ")
  692. print("                | |              | |     *        ")
  693. print("                | |              | |              ")
  694. print("     *          | |              | |              ")
  695. print("                | |              | |              ")
  696. print("                | |              | |              ")
  697. print("   *         *  | |              | |           *  ")
  698. print("                | '--------------' |              ")
  699. print("                 '----------------'   *           ")
  700. sleep(.2)
  701. term.clear()
  702. bTitle()
  703. term.setCursorPos(1,7)
  704. print("               .----------------.                 ")
  705. print("        *     | .--------------. |   *            ")
  706. print("              | |              | |                ")
  707. print("    *         | |              | |          *     ")
  708. print("              | |              | |                ")
  709. print("              | |              | |    *           ")
  710. print("              | |              | |                ")
  711. print("   *       *  | |              | |                ")
  712. print("              | |              | |             *  ")
  713. print("              | '--------------' |                ")
  714. print("       *       '----------------'  *              ")
  715. sleep(.2)
  716. term.clear()
  717. bTitle()
  718. term.setCursorPos(1,7)
  719. print("                .----------------. ")
  720. print("               | .--------------. |")
  721. print("               | |              | |")
  722. print("               | |              | |")
  723. print("               | |              | |")
  724. print("               | |              | |")
  725. print("               | |              | |")
  726. print("               | |              | |")
  727. print("               | |              | |")
  728. print("               | '--------------' |")
  729. print("                '----------------' ")
  730. sleep(1.5)
  731. ans()
  732. end
  733. local function block()
  734. start()
  735. while true do
  736. local event, p1 = os.pullEvent("key")
  737.     if p1 == 28 then
  738.     shake()
  739.     sleep(2)
  740.     start()
  741.     elseif p1 == 14 then break
  742.     end
  743. end
  744. end
  745.     -- slots functions
  746. local function cardtop(x,y)
  747. term.setCursorPos(x,y)
  748. write([[ .------------. ]])
  749. term.setCursorPos(x,y+1)
  750. write([[| .----------. |]])
  751. term.setCursorPos(x,y+2)
  752. write([[| |          | |]])
  753. term.setCursorPos(x,y+3)
  754. write([[| | .------. | |]])
  755. term.setCursorPos(x,y+4)
  756. end
  757. local function cardbase(x,y)
  758. term.setCursorPos(x,y+8)
  759. write([[| | '------' | |]])
  760. term.setCursorPos(x,y+9)
  761. write([[| |          | |]])
  762. term.setCursorPos(x,y+10)
  763. write([[| '----------' |]])
  764. term.setCursorPos(x,y+11)
  765. write([[ '------------' ]])
  766. end
  767. local function numtop(n,x,y)
  768. if symbol[n] == "10" then
  769. term.setCursorPos(x,y+4)
  770. write([[| | |]]..symbol[n]..[[--. | | |]])
  771. else
  772. term.setCursorPos(x,y+4)
  773. write([[| | |]]..symbol[n]..[[.--. | | |]])
  774. end
  775. end
  776. local function numbase(n,x,y)
  777. if symbol[n] == "10" then
  778. term.setCursorPos(x,y+7)
  779. write([[| | | '--]]..symbol[n]..[[| | |]])
  780. else
  781. term.setCursorPos(x,y+7)
  782. write([[| | | '--']]..symbol[n]..[[| | |]])
  783. end
  784. end
  785. local function spade(x,y)
  786. term.setCursorPos(x,y+5)
  787. write([[| | | :/\: | | |]])
  788. term.setCursorPos(x,y+6)
  789. write([[| | | (__) | | |]])
  790. end
  791. local function heart(x,y)
  792. term.setCursorPos(x,y+5)
  793. write([[| | | (\/) | | |]])
  794. term.setCursorPos(x,y+6)
  795. write([[| | | :\/: | | |]])
  796. end
  797. local function club(x,y)
  798. term.setCursorPos(x,y+5)
  799. write([[| | | :(): | | |]])
  800. term.setCursorPos(x,y+6)
  801. write([[| | | ()() | | |]])
  802. end
  803. local function diamond(x,y)
  804. term.setCursorPos(x,y+5)
  805. write([[| | | :/\: | | |]])
  806. term.setCursorPos(x,y+6)
  807. write([[| | | :\/: | | |]])
  808. end
  809. local function slot(pos)
  810. local c = math.random(1,4)
  811. local n = math.random(1,13)
  812. cardtop(pos,1)
  813. numtop(n,pos,1)
  814. if c == 1 then
  815. spade(pos,1)
  816. elseif c == 2 then
  817. heart(pos,1)
  818. elseif c == 3 then
  819. club(pos,1)
  820. elseif c == 4 then
  821. diamond(pos,1)
  822. end
  823. numbase(n,pos,1)
  824. cardbase(pos,1)
  825. return c,n
  826. end
  827. local function spin()
  828. for cnt = 1, 10 do
  829. slot(2)
  830. slot(18)
  831. slot(34)
  832. sleep(cnt/30)
  833. end
  834. end
  835. local function allsuitsmatch(result)
  836. return (result[1] == result[3] and result[3] == result[5] and result[5] ==result[1])
  837. end
  838. local function allvaluesmatch(result)
  839. return (result[2] == result[4] and result[4] == result[6] and result[6] ==result[2] )
  840. end
  841. local function isroyalflush(result)
  842. local Fresult = false
  843. if result[2] > 10 and result[4] > 10 and result[6] > 10 then
  844. if result[2] ~= result[4] and result[4] ~= result[6] and result[6] ~= result[2] then return true  -- royal flush discounting Ace
  845. end
  846. end
  847.  
  848. if result[2] == 1 and result[4] > 11 and result[6] > 11 and result[4] ~= result[6] then return true --royal flush including ace, condition 1
  849. elseif result[4] == 1 and result[6] > 11 and result[2] > 11 and result[6] ~= result[2] then return true --royal flush including ace, condition 2
  850. elseif result[6] == 1 and result[2] > 11 and result[4] > 11 and result[2] ~= result[4] then return true --royal flush including ace, condition 3
  851. end
  852.  
  853. return false
  854. end
  855. local function testwin(results)
  856. ------------------------------
  857. --  This function has been  --
  858. -- brought to you by Pharap --
  859. ------------------------------
  860. local value = 0
  861. if allsuitsmatch(results) then value = 1 end -- suits match
  862. if allvaluesmatch(results) then value = 2 end -- values match
  863. if allsuitsmatch(results) and allvaluesmatch(results) then value = 3 end --suits and values match
  864. if isroyalflush(results) then value = 4 end -- royal flush
  865. if isroyalflush(results) and allsuitsmatch(results) then value = 5 end -- royal flush of all matching suits
  866. if isroyalflush(results) and allvaluesmatch(results) then value = "wtfiswrongwithyou,howthehelldidyoucausesuchabloodystupiderror" return "error"  end-- lol, like this would actually happen
  867. return value
  868. end
  869. local function slots()
  870. term.clear()
  871. sTitle()
  872. slot(2)
  873. slot(18)
  874. slot(34)
  875. while true do
  876. local event, p1 = os.pullEvent()
  877.     if event == "key" then
  878.         if p1 == 28 then
  879.             spin()  
  880.             local s1, n1 = slot(2)
  881.             local s2, n2 = slot(18)
  882.             local s3, n3 = slot(34)
  883.             sleep(2)
  884.         local results = {s1,n1,s2,n2,s3,n3}
  885.          --local results = {3,1,3,12,3,13}
  886.         local condition = testwin(results)
  887.             if condition == 0 then
  888.                 loser()
  889.                 term.clear()
  890.                 sTitle()
  891.                 slot(2)
  892.                 slot(18)
  893.                 slot(34)
  894.             elseif condition == 1 then --suits
  895.                 jackpot()
  896.                 term.clear()
  897.                 sTitle()
  898.                 slot(2)
  899.                 slot(18)
  900.                 slot(34)
  901.             elseif condition == 2 then --values
  902.                 jackpot()
  903.                 term.clear()
  904.                 sTitle()
  905.                 slot(2)
  906.                 slot(18)
  907.                 slot(34)
  908.             elseif condition == 3 then --suits and values
  909.                 jackpot()
  910.                 term.clear()
  911.                 sTitle()
  912.                 slot(2)
  913.                 slot(18)
  914.                 slot(34)
  915.             elseif condition == 4 then --royal flush
  916.                 jackpot()
  917.                 term.clear()
  918.                 sTitle()
  919.                 slot(2)
  920.                 slot(18)
  921.                 slot(34)
  922.             elseif condition == 5 then --royal flush suited
  923.                 jackpot()
  924.                 term.clear()
  925.                 sTitle()
  926.                 slot(2)
  927.                 slot(18)
  928.                 slot(34)
  929.             end
  930.         elseif p1 == 14 then break
  931.         end
  932.     end
  933. end
  934. end
  935. -- game functions
  936. local function games()
  937. while true do
  938. gPage()
  939. local input = opt(gMenu,10)
  940.     if input == 1 then
  941.         dice()
  942.     elseif input == 2 then
  943.         block()
  944.     elseif input == 3 then
  945.         slots()
  946.     elseif input == 4 then break
  947.     end
  948. end
  949. end
  950. -- action functions
  951. local function time()
  952. while pM do
  953. local mX,mY = mon.getSize()
  954.     local t = os.time()
  955.     time = textutils.formatTime(t,false)
  956.     mon.setCursorPos(mX-9,3)
  957.     mon.write(time)
  958.     sleep(0)
  959. end
  960. end
  961. local function saveState(saveTable)
  962.     local file = fs.open("status", "w")
  963.     if file then
  964.         for eNum, eInfo in ipairs(saveTable) do
  965.             file.writeLine(eInfo.type..","..eInfo.color..","..eInfo.status)
  966.         end
  967.         file.close()
  968.     end
  969. end
  970. local function loadState()
  971.     local loadTable = {}
  972.     local file = fs.open("status", "r")
  973.     if file then
  974.         readLine = file.readLine()
  975.         while readLine do
  976.             local lineTable = {}
  977.             lineTable.type, lineTable.color, lineTable.status = string.match(readLine, "(%w+),(%w+),(%w+)")
  978.             if lineTable.type then
  979.                 table.insert(loadTable, lineTable)
  980.             end
  981.             readLine = file.readLine()
  982.         end
  983.         file.close()
  984.     end
  985.     return loadTable
  986. end
  987. local function menuOpt()
  988. local btn1 = {1,1,menu[1]}
  989. local btn2 = {2,1,menu[2]}
  990. local btn3 = {1,2,menu[3]}
  991. local btn4 = {2,2,menu[4]}
  992. local btn5 = {1,3,menu[5]}
  993. local btn6 = {2,3,menu[6]}
  994. local a1 = string.len("   ["..btn1[3].."]   "..btn2[3].." ")/2
  995. local a2 = string.len("    "..btn1[3].."   ["..btn2[3].."]")/2
  996. local a3 = string.len("    "..btn1[3].."    "..btn2[3].." ")/2
  997. local b1 = string.len("   ["..btn3[3].."]   "..btn4[3].." ")/2
  998. local b2 = string.len("    "..btn3[3].."   ["..btn4[3].."]")/2
  999. local b3 = string.len("    "..btn3[3].."    "..btn4[3].." ")/2
  1000. local c1 = string.len("   ["..btn5[3].."]   "..btn6[3].." ")/2
  1001. local c2 = string.len("    "..btn5[3].."   ["..btn6[3].."]")/2
  1002. local c3 = string.len("    "..btn5[3].."    "..btn6[3].." ")/2
  1003. local x,y = term.getSize()
  1004. local curx=btn1[1]
  1005. local cury=btn1[2]
  1006. while true do
  1007. --test for looping
  1008. if curx<btn1[1] and cury==btn1[2] then curx=btn2[1] cury=btn2[2]
  1009. elseif curx>btn2[1] and cury==btn2[2] then curx=btn1[1] cury=btn1[2]
  1010. elseif curx<btn3[1] and cury==btn3[2] then curx=btn4[1] cury=btn4[2]
  1011. elseif curx>btn4[1] and cury==btn4[2] then curx=btn3[1] cury=btn3[2]
  1012. elseif curx<btn5[1] and cury==btn5[2] then curx=btn6[1] cury=btn6[2]
  1013. elseif curx>btn6[1] and cury==btn6[2] then curx=btn5[1] cury=btn5[2]
  1014. elseif cury<btn1[2] and curx==btn1[1] then cury=btn5[2] curx=btn5[1]
  1015. elseif cury>btn5[2] and curx==btn5[1] then cury=btn1[2] curx=btn1[1]
  1016. elseif cury<btn2[2] and curx==btn2[1] then cury=btn6[2] curx=btn6[1]
  1017. elseif cury>btn6[2] and curx==btn6[1] then cury=btn2[2] curx=btn2[1]
  1018. end
  1019. -- line 1 of options
  1020. if curx==btn1[1] and cury==btn1[2] then
  1021. local x = (x/2)-a1
  1022. term.setCursorPos(x,8)
  1023. print("   ["..btn1[3].."]   "..btn2[3].." ")
  1024. elseif curx==btn2[1] and cury==btn2[2] then
  1025. local x = (x/2)-a2
  1026. term.setCursorPos(x,8)
  1027. print("    "..btn1[3].."   ["..btn2[3].."]")
  1028. else
  1029. local x = (x/2)-a3
  1030. term.setCursorPos(x,8)
  1031. print("    "..btn1[3].."    "..btn2[3].." ")
  1032. end
  1033. -- line 2 of options
  1034. if curx==btn3[1] and cury==btn3[2] then
  1035. local x = (x/2)-b1
  1036. term.setCursorPos(x,10)
  1037. print("   ["..btn3[3].."]   "..btn4[3].." ")
  1038. elseif curx==btn4[1] and cury==btn4[2] then
  1039. local x = (x/2)-b2
  1040. term.setCursorPos(x,10)
  1041. print("    "..btn3[3].."   ["..btn4[3].."]")
  1042. else
  1043. local x = (x/2)-b3
  1044. term.setCursorPos(x,10)
  1045. print("    "..btn3[3].."    "..btn4[3].." ")
  1046. end
  1047. -- line 3 of options
  1048. if curx==btn5[1] and cury==btn5[2] then
  1049. local x = (x/2)-c1
  1050. term.setCursorPos(x,12)
  1051. print("   ["..btn5[3].."]   "..btn6[3].." ")
  1052. elseif curx==btn6[1] and cury==btn6[2] then
  1053. local x = (x/2)-c2
  1054. term.setCursorPos(x,12)
  1055. print("    "..btn5[3].."   ["..btn6[3].."]")
  1056. else
  1057. local x = (x/2)-c3
  1058. term.setCursorPos(x,12)
  1059. print("    "..btn5[3].."    "..btn6[3].." ")
  1060. end
  1061.  
  1062. e, k = os.pullEvent("key")
  1063. if k==203 then curx = curx - 1 --left
  1064. elseif k==205 then curx = curx + 1 --right
  1065. elseif k==200 then cury = cury - 1 --up
  1066. elseif k==208 then cury = cury + 1 --down
  1067. elseif k==28 then break --enter
  1068. end
  1069. end
  1070.  
  1071. if curx == 1 and cury == 1 then return "1" end
  1072. if curx == 2 and cury == 1 then return "2" end
  1073. if curx == 1 and cury == 2 then return "3" end
  1074. if curx == 2 and cury == 2 then return "4" end
  1075. if curx == 1 and cury == 3 then return "5" end
  1076. if curx == 2 and cury == 3 then return "6" end
  1077. end
  1078. local function yN()
  1079. local n=1
  1080. while true do
  1081. local x, y=term.getCursorPos()
  1082. term.clearLine()
  1083. if n==1 then write(">YES<   NO") else write (" YES   >NO<") end
  1084. term.setCursorPos(x, y)
  1085. a, b=os.pullEvent()
  1086. while a~="key" do a, b=os.pullEvent() end
  1087. if b==203 and n==2 then n=1 end
  1088. if b==205 and n==1 then n=2 end
  1089. if b==28 then print("") break end
  1090. end
  1091. if n==1 then return "true" end
  1092. if n==2 then return "false" end
  1093. return false
  1094. end
  1095. local function login()
  1096. while true do
  1097. newPage()
  1098. term.setCursorPos(1,6)
  1099. term.clearLine()
  1100. print("Please enter User ID:")
  1101. local user = read()
  1102. controlTable = loadState()
  1103.     for eNum,dInfo in ipairs(controlTable) do
  1104.         if dInfo.type == "Admin"  and user == dInfo.color then
  1105.             newPage()
  1106.             term.setCursorPos(1,6)
  1107.             term.clearLine()
  1108.             print("Please enter User password:")
  1109.             local pass = read("*")
  1110.             if dInfo.type == "Admin" and pass == dInfo.status then
  1111.                 return admin,true
  1112.             end break
  1113.         elseif dInfo.type == "User"  and user == dInfo.color then
  1114.             newPage()
  1115.             term.setCursorPos(1,6)
  1116.             term.clearLine()
  1117.             print("Please enter User password:")
  1118.             local pass = read("*")
  1119.             if dInfo.type == "User" and pass == dInfo.status then
  1120.                 return user,true
  1121.             end break
  1122.         end
  1123.     end
  1124. end
  1125. end
  1126. local function colorConvert(color)
  1127. if color > 1 then return 2^(color - 2)
  1128. else return "redstone"
  1129. end
  1130. end
  1131. local function firstRun()
  1132. if fs.exists("status") then fs.delete("status") end
  1133. --temporary save file
  1134. local deviceTable = {type="Admin"}
  1135. deviceTable.color = "admin_name_temp"
  1136. deviceTable.status = "admin_pass_temp"
  1137. table.insert(controlTable,deviceTable)
  1138. saveState(controlTable)
  1139. local deviceTable = {type="User"}
  1140. deviceTable.color = "user_name_temp"
  1141. deviceTable.status = "user_pass_temp"
  1142. table.insert(controlTable,deviceTable)
  1143. saveState(controlTable)
  1144. local deviceTable = {type="Lights"}
  1145. deviceTable.color = "lights_color_temp"
  1146. deviceTable.status = "lights_color_temp"
  1147. table.insert(controlTable,deviceTable)
  1148. saveState(controlTable)
  1149. local deviceTable = {type="Industrialcraft2"}
  1150. deviceTable.color = "ic2_control_temp"
  1151. deviceTable.status = "ic2_exists_temp"
  1152. table.insert(controlTable,deviceTable)
  1153. saveState(controlTable)
  1154. local deviceTable = {type="IC2Power"}
  1155. deviceTable.color = "power_color_temp"
  1156. deviceTable.status = "power_status_temp"
  1157. table.insert(controlTable,deviceTable)
  1158. saveState(controlTable)
  1159. local deviceTable = {type="Reactor"}
  1160. deviceTable.color = "reactor_color_temp"
  1161. deviceTable.status = "reactor_status_temp"
  1162. table.insert(controlTable,deviceTable)
  1163. saveState(controlTable)
  1164. local deviceTable = {type="Coolant"}
  1165. deviceTable.color = "cool_color_temp"
  1166. deviceTable.status = "cool_status_temp"
  1167. table.insert(controlTable,deviceTable)
  1168. saveState(controlTable)
  1169. local deviceTable = {type="EnergyStorage"}
  1170. deviceTable.color = "energy_color_temp"
  1171. deviceTable.status = "energy_status_temp"
  1172. table.insert(controlTable,deviceTable)
  1173. saveState(controlTable)
  1174. local deviceTable = {type="Macerator"}
  1175. deviceTable.color = "macerator_color_temp"
  1176. deviceTable.status = "macerator_status_temp"
  1177. table.insert(controlTable,deviceTable)
  1178. saveState(controlTable)
  1179. local deviceTable = {type="Furnace"}
  1180. deviceTable.color = "furnace_color_temp"
  1181. deviceTable.status = "furnace_status_temp"
  1182. table.insert(controlTable,deviceTable)
  1183. saveState(controlTable)
  1184. local deviceTable = {type="Compressor"}
  1185. deviceTable.color = "compressor_color_temp"
  1186. deviceTable.status = "compressor_status_temp"
  1187. table.insert(controlTable,deviceTable)
  1188. saveState(controlTable)
  1189. local deviceTable = {type="Extractor"}
  1190. deviceTable.color = "extractor_color_temp"
  1191. deviceTable.status = "extractor_status_temp"
  1192. table.insert(controlTable,deviceTable)
  1193. saveState(controlTable)
  1194. local deviceTable = {type="RedPower2"}
  1195. deviceTable.color = "rp2_control_temp"
  1196. deviceTable.status = "rp2_exists_temp"
  1197. table.insert(controlTable,deviceTable)
  1198. saveState(controlTable)
  1199. local deviceTable = {type="RedPowerPump"}
  1200. deviceTable.color = "rp2pump_color_temp"
  1201. deviceTable.status = "rp2pump_status_temp"
  1202. table.insert(controlTable,deviceTable)
  1203. saveState(controlTable)
  1204. local deviceTable = {type="Blockbreaker"}
  1205. deviceTable.color = "breaker_color_temp"
  1206. deviceTable.status = "breaker_status_temp"
  1207. table.insert(controlTable,deviceTable)
  1208. saveState(controlTable)
  1209. local deviceTable = {type="Buildcraft"}
  1210. deviceTable.color = "bc_control_temp"
  1211. deviceTable.status = "bc_exists_temp"
  1212. table.insert(controlTable,deviceTable)
  1213. saveState(controlTable)
  1214. local deviceTable = {type="MiningWell"}
  1215. deviceTable.color = "miningwell_color_temp"
  1216. deviceTable.status = "miningwell_status_temp"
  1217. table.insert(controlTable,deviceTable)
  1218. saveState(controlTable)
  1219. local deviceTable = {type="Quarry"}
  1220. deviceTable.color = "quarry_color_temp"
  1221. deviceTable.status = "quarry_status_temp"
  1222. table.insert(controlTable,deviceTable)
  1223. saveState(controlTable)
  1224. local deviceTable = {type="BuildcraftPump"}
  1225. deviceTable.color = "bcpump_color_temp"
  1226. deviceTable.status = "bcpump_status_temp"
  1227. table.insert(controlTable,deviceTable)
  1228. saveState(controlTable)
  1229. local deviceTable = {type="Forcefield"}
  1230. deviceTable.color = "field_color_temp"
  1231. deviceTable.status = "field_status_temp"
  1232. table.insert(controlTable,deviceTable)
  1233. saveState(controlTable)
  1234.  
  1235. --run system
  1236. while true do
  1237. title()
  1238. local deviceTable = {type="Admin"}
  1239.     while true do
  1240.     print("Please enter Administrator name:")
  1241.     deviceTable.color  = read()
  1242.         if deviceTable.color == "" then
  1243.         print("Admin name cannot be blank")
  1244.         sleep(1)
  1245.         title()
  1246.         else break
  1247.         end
  1248.     end
  1249.     title()
  1250.     while true do
  1251.         while true do
  1252.         print("Please enter Administrator password:")
  1253.         tempadmin = read("*")
  1254.             if tempadmin == "" then
  1255.             print("Password cannot be blank")
  1256.             sleep(1)
  1257.             title()
  1258.             else break
  1259.             end
  1260.         end
  1261.         title()
  1262.         while true do
  1263.         print("Please re-enter password:")
  1264.         tempadmin2 = read("*")
  1265.             if tempadmin2 == "" then
  1266.             print("Password cannot be blank")
  1267.             sleep(1)
  1268.             title()
  1269.             else break
  1270.             end
  1271.         end
  1272.         title()
  1273.             if tempadmin ~= tempadmin2 then
  1274.             print("Passwords do not match. Please try again.")
  1275.             sleep(1)
  1276.             title()
  1277.             elseif tempadmin == tempadmin2 then
  1278.             deviceTable.status = tempadmin break
  1279.             end
  1280.         end
  1281.         title()
  1282.         print("Thank you. Admin profile created.")
  1283.         sleep(1)
  1284.         table.insert(controlTable,1,deviceTable)
  1285.         table.remove(controlTable,2,deviceTable)
  1286.         saveState(controlTable)
  1287.         tempadmin = nil
  1288.         tempadmin2 = nil
  1289.         break
  1290.         end
  1291. local deviceTable = {type="User"}
  1292. while true do
  1293. title()
  1294. print("Please enter User name:")
  1295. tempusername = read()
  1296.     if tempusername == adminname then
  1297.     print("Cannot have User name the same as Administrator name.")
  1298.     sleep(1)
  1299.     title()
  1300.     elseif tempusername == "" then
  1301.     print("User name cannot be blank.")
  1302.     sleep(1)
  1303.     title()
  1304.     else
  1305.     deviceTable.color = tempusername
  1306.     break
  1307.     end
  1308. end
  1309. while true do
  1310. title()
  1311.     while true do
  1312.         while true do
  1313.         print("Please enter User password:")
  1314.         tempuser = read("*")
  1315.             if tempuser == "" then
  1316.             print("Password cannot be blank.")
  1317.             sleep(1)
  1318.             title()
  1319.             else break
  1320.             end
  1321.         end
  1322.     title()
  1323.         while true do
  1324.         title()
  1325.         print("Pleas re-enter password:")
  1326.         tempuser2 = read("*")
  1327.             if tempuser2 == "" then
  1328.             print("Password cannot be blank.")
  1329.             sleep(1)
  1330.             title()
  1331.             else break
  1332.             end
  1333.         end
  1334.         title()
  1335.         if tempuser ~= tempuser2 then
  1336.         print("Passwords do not match. Please try again.")
  1337.         sleep(1)
  1338.         title()
  1339.         elseif tempuser == tempuser2 then
  1340.         deviceTable.status = tempuser break
  1341.         end
  1342.     end
  1343. title()
  1344. print("Thank you. User profile created.")
  1345. sleep(1)
  1346. break
  1347. end
  1348. table.insert(controlTable,2,deviceTable)
  1349. table.remove(controlTable,3,devicetable)
  1350. saveState(controlTable)
  1351. tempusername = nil
  1352. tempuser = nil
  1353. tempuser2 = nil
  1354. local deviceTable = {type="Lights"}
  1355. title()
  1356. print("Do you have lighting that you want to control?")
  1357. deviceTable.status = yN()
  1358.     if deviceTable.status == "true" then
  1359.     --deviceTable.type = "Lights"
  1360.     term.clear()
  1361.     term.setCursorPos(1,9)
  1362.     print("           What color are you using?")
  1363.     sleep(1.5)
  1364.     deviceTable.color = colorConvert(opt(colorOpt,0))
  1365.     deviceTable.status = "false"
  1366.     table.insert(controlTable,3,deviceTable)
  1367.     table.remove(controlTable,4,devicetable)
  1368.     saveState(controlTable)
  1369.     else deviceTable.status = "false"
  1370.     deviceTable.color = "false"
  1371.     table.insert(controlTable,3,deviceTable)
  1372.     table.remove(controlTable,4,devicetable)
  1373.     saveState(controlTable)
  1374.     end
  1375. title()
  1376. --determine mods
  1377. while true do
  1378. print("What mods do you have?")
  1379. print("Please indicate ALL mods installed.")
  1380. sleep(2)
  1381. title()
  1382. local mods = opt(modslist,9)
  1383.     if mods == 1 then  --IndustrialCraft2
  1384.         local modTable = {type="IndustrialCraft2"}
  1385.         modTable.status = "true"
  1386.         title()
  1387.         print("Do you want to control this mod?")
  1388.         local input = yN()
  1389.         if input == "true" then
  1390.             modTable.color = "true"
  1391.             table.insert(controlTable,4,modTable)
  1392.             table.remove(controlTable,5,devicetable)
  1393.             saveState(controlTable)
  1394.             title()
  1395.             print("What type of power are you using?")
  1396.             deviceTable.type = tostring(opt(IC2power,7))
  1397.             if deviceTable.type == "7" then
  1398.                 deviceTable.type = "Power"
  1399.                 deviceTable.color = "false"
  1400.                 deviceTable.status = "false"
  1401.                 table.insert(controlTable,5,deviceTable)
  1402.                 table.remove(controlTable,6,devicetable)
  1403.                 saveState(controlTable)
  1404.                 local deviceTable = {type="Reactor"}
  1405.                 title()
  1406.                 print("Do you want this computer to control your reactor?")
  1407.                 deviceTable.status = yN()
  1408.                 if deviceTable.status == "true" then
  1409.                     term.clear()
  1410.                     term.setCursorPos(1,9)
  1411.                     print("           What color are you using?")
  1412.                     sleep(1.5)
  1413.                     deviceTable.color = colorConvert(opt(colorOpt,0))
  1414.                     table.insert(controlTable,6,deviceTable)
  1415.                     table.remove(controlTable,7,deviceTable)
  1416.                     saveState(controlTable)
  1417.                 else   
  1418.                     local deviceTable = {type="Reactor"}
  1419.                     deviceTable.status = "false"
  1420.                     deviceTable.color = "false"
  1421.                     table.insert(controlTable,6,deviceTable)
  1422.                     table.remove(controlTable,7,deviceTable)
  1423.                     saveState(controlTable)
  1424.                 end
  1425.                 local deviceTable = {type="Coolant"}
  1426.                 deviceTable.type = "Coolant"
  1427.                 title()
  1428.                 print("Do you have an independant coolant system?")
  1429.                 deviceTable.status = yN()
  1430.                 if deviceTable.status == "true" then
  1431.                     term.clear()
  1432.                     term.setCursorPos(1,9)
  1433.                     print("           What color are you using?")
  1434.                     sleep(1.5)
  1435.                     deviceTable.color = colorConvert(opt(colorOpt,0))
  1436.                     table.insert(controlTable,7,deviceTable)
  1437.                     table.remove(controlTable,8,deviceTable)
  1438.                     saveState(controlTable)
  1439.                 else
  1440.                     deviceTable.status = "false"
  1441.                     table.insert(controlTable,7,deviceTable)
  1442.                     table.remove(controlTable,8,deviceTable)
  1443.                     saveState(controlTable)
  1444.                 end
  1445.             elseif deviceTable.type == "1" then
  1446.                 local deviceTable = {type="NoIC2Power"}
  1447.                 deviceTable.status = "false"
  1448.                 deviceTable.color = "false"
  1449.                 table.insert(controlTable,5,deviceTable)
  1450.                 table.remove(controlTable,6,devicetable)
  1451.                 saveState(controlTable)
  1452.                 local deviceTable = {type="Reactor"}
  1453.                 deviceTable.status = "false"
  1454.                 deviceTable.color = "false"
  1455.                 table.insert(controlTable,6,deviceTable)
  1456.                 table.remove(controlTable,7,deviceTable)
  1457.                 saveState(controlTable)
  1458.                 local deviceTable = {type="Coolant"}
  1459.                 deviceTable.status = "false"
  1460.                 deviceTable.color = "false"
  1461.                 table.insert(controlTable,7,deviceTable)
  1462.                 table.remove(controlTable,8,deviceTable)
  1463.                 saveState(controlTable)
  1464.             elseif deviceTable.type == "2" then
  1465.                 deviceTable.type = "Generator"
  1466.                 deviceTable.color = "none"
  1467.                 deviceTable.status = "none"
  1468.                 table.insert(controlTable,5,deviceTable)
  1469.                 table.remove(controlTable,6,devicetable)
  1470.                 saveState(controlTable)
  1471.                 local deviceTable = {type="Reactor"}
  1472.                 deviceTable.status = "false"
  1473.                 deviceTable.color = "false"
  1474.                 table.insert(controlTable,6,deviceTable)
  1475.                 table.remove(controlTable,7,deviceTable)
  1476.                 saveState(controlTable)
  1477.                 local deviceTable = {type="Coolant"}
  1478.                 deviceTable.status = "false"
  1479.                 deviceTable.color = "false"
  1480.                 table.insert(controlTable,7,deviceTable)
  1481.                 table.remove(controlTable,8,deviceTable)
  1482.                 saveState(controlTable)
  1483.             elseif deviceTable.type =="3" then
  1484.                 deviceTable.type = "Geothermal"
  1485.                 deviceTable.color = "none"
  1486.                 deviceTable.status = "none"
  1487.                 table.insert(controlTable,5,deviceTable)
  1488.                 table.remove(controlTable,6,devicetable)
  1489.                 saveState(controlTable)
  1490.                 local deviceTable = {type="Reactor"}
  1491.                 deviceTable.status = "false"
  1492.                 deviceTable.color = "false"
  1493.                 table.insert(controlTable,6,deviceTable)
  1494.                 table.remove(controlTable,7,deviceTable)
  1495.                 saveState(controlTable)
  1496.                 local deviceTable = {type="Coolant"}
  1497.                 deviceTable.status = "false"
  1498.                 deviceTable.color = "false"
  1499.                 table.insert(controlTable,7,deviceTable)
  1500.                 table.remove(controlTable,8,deviceTable)
  1501.                 saveState(controlTable)
  1502.             elseif deviceTable.type == "4" then
  1503.                 deviceTable.type = "WaterMill"
  1504.                 deviceTable.color = "none"
  1505.                 deviceTable.status = "none"
  1506.                 table.insert(controlTable,5,deviceTable)
  1507.                 table.remove(controlTable,6,devicetable)
  1508.                 saveState(controlTable)
  1509.                 local deviceTable = {type="Reactor"}
  1510.                 deviceTable.status = "false"
  1511.                 deviceTable.color = "false"
  1512.                 table.insert(controlTable,6,deviceTable)
  1513.                 table.remove(controlTable,7,deviceTable)
  1514.                 saveState(controlTable)
  1515.                 local deviceTable = {type="Coolant"}
  1516.                 deviceTable.status = "false"
  1517.                 deviceTable.color = "false"
  1518.                 table.insert(controlTable,7,deviceTable)
  1519.                 table.remove(controlTable,8,deviceTable)
  1520.                 saveState(controlTable)
  1521.             elseif deviceTable.type == "5" then
  1522.                 deviceTable.type = "WindMill"
  1523.                 deviceTable.color = "none"
  1524.                 deviceTable.status = "none"
  1525.                 table.insert(controlTable,5,deviceTable)
  1526.                 table.remove(controlTable,6,devicetable)
  1527.                 saveState(controlTable)
  1528.                 local deviceTable = {type="Reactor"}
  1529.                 deviceTable.status = "false"
  1530.                 deviceTable.color = "false"
  1531.                 table.insert(controlTable,6,deviceTable)
  1532.                 table.remove(controlTable,7,deviceTable)
  1533.                 saveState(controlTable)
  1534.                 local deviceTable = {type="Coolant"}
  1535.                 deviceTable.status = "false"
  1536.                 deviceTable.color = "false"
  1537.                 table.insert(controlTable,7,deviceTable)
  1538.                 table.remove(controlTable,8,deviceTable)
  1539.                 saveState(controlTable)
  1540.             elseif deviceTable.type == "6" then
  1541.                 deviceTable.type = "SolarPanel"
  1542.                 deviceTable.color = "none"
  1543.                 deviceTable.status = "none"
  1544.                 table.insert(controlTable,5,deviceTable)
  1545.                 table.remove(controlTable,6,devicetable)
  1546.                 saveState(controlTable)
  1547.                 local deviceTable = {type="Reactor"}
  1548.                 deviceTable.status = "false"
  1549.                 deviceTable.color = "false"
  1550.                 table.insert(controlTable,6,deviceTable)
  1551.                 table.remove(controlTable,7,deviceTable)
  1552.                 saveState(controlTable)
  1553.                 local deviceTable = {type="Coolant"}
  1554.                 deviceTable.status = "false"
  1555.                 deviceTable.color = "false"
  1556.                 table.insert(controlTable,7,deviceTable)
  1557.                 table.remove(controlTable,8,deviceTable)
  1558.                 saveState(controlTable)
  1559.             end
  1560.             local deviceTable = {type="EnergyStorage"}
  1561.             title()
  1562.             print("What type of energy storage are you using?")
  1563.             sleep(2)
  1564.             deviceTable.type = tostring(opt(eType,7))
  1565.             if deviceTable.type == "1" then
  1566.                 deviceTable.color = "false"
  1567.                 deviceTable.status = "false"
  1568.                 table.insert(controlTable,8,deviceTable)
  1569.                 table.remove(controlTable,9,deviceTable)
  1570.                 saveState(controlTable)
  1571.             elseif deviceTable.type == "2" then
  1572.                 deviceTable.type = "BatBox"
  1573.                 term.clear()
  1574.                 term.setCursorPos(1,9)
  1575.                 print("           What color are you using?")
  1576.                 sleep(1.5)
  1577.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1578.                 deviceTable.status = "None"
  1579.                 table.insert(controlTable,8,deviceTable)
  1580.                 table.remove(controlTable,9,deviceTable)
  1581.                 saveState(controlTable)
  1582.             elseif deviceTable.type == "3" then
  1583.                 deviceTable.type = "MFE"
  1584.                 term.clear()
  1585.                 term.setCursorPos(1,9)
  1586.                 print("           What color are you using?")
  1587.                 sleep(1.5)
  1588.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1589.                 deviceTable.status = "None"
  1590.                 table.insert(controlTable,8,deviceTable)
  1591.                 table.remove(controlTable,9,deviceTable)
  1592.                 saveState(controlTable)
  1593.             elseif deviceTable.type == "4" then
  1594.                 deviceTable.type = "MFSU"
  1595.                 term.clear()
  1596.                 term.setCursorPos(1,9)
  1597.                 print("           What color are you using?")
  1598.                 sleep(1.5)
  1599.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1600.                 deviceTable.status = "None"
  1601.                 table.insert(controlTable,8,deviceTable)
  1602.                 table.remove(controlTable,9,deviceTable)
  1603.                 saveState(controlTable)
  1604.             end
  1605.             local deviceTable = {type="Macerator"}
  1606.             title()
  1607.             print("Would you like to control a Macerator?")
  1608.             deviceTable.status = yN()
  1609.             if deviceTable.status == "true" then
  1610.                 term.clear()
  1611.                 term.setCursorPos(1,9)
  1612.                 print("           What color are you using?")
  1613.                 sleep(1.5)
  1614.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1615.                 deviceTable.status = "false"
  1616.                 table.insert(controlTable,9,deviceTable)
  1617.                 table.remove(controlTable,10,deviceTable)
  1618.                 saveState(controlTable)
  1619.             else deviceTable.status = "false"
  1620.                 deviceTable.color = "false"
  1621.                 table.insert(controlTable,9,deviceTable)
  1622.                 table.remove(controlTable,10,deviceTable)
  1623.                 saveState(controlTable)
  1624.             end
  1625.             local deviceTable = {type="Furnace"}
  1626.             title()
  1627.             print("Would you like to control an IC2 Furnace?")
  1628.             furnace = yN()
  1629.             if furnace == "true" then
  1630.                 term.clear()
  1631.                 term.setCursorPos(1,9)
  1632.                 print("           What color are you using?")
  1633.                 sleep(1.5)
  1634.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1635.                 deviceTable.status = "false"
  1636.                 table.insert(controlTable,10,deviceTable)
  1637.                 table.remove(controlTable,11,deviceTable)
  1638.                 saveState(controlTable)
  1639.             else deviceTable.status = "false"
  1640.                 deviceTable.color = "false"
  1641.                 table.insert(controlTable,10,deviceTable)
  1642.                 table.remove(controlTable,11,deviceTable)
  1643.                 saveState(controlTable)
  1644.             end
  1645.             local deviceTable = {type="Compressor"}
  1646.             title()
  1647.             print("Would you like to control an IC2 Compressor?")
  1648.             deviceTable.status = yN()
  1649.             if deviceTable.status == "true" then
  1650.                 term.clear()
  1651.                 term.setCursorPos(1,9)
  1652.                 print("           What color are you using?")
  1653.                 sleep(1.5)
  1654.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1655.                 deviceTable.status = "false"
  1656.                 table.insert(controlTable,11,deviceTable)
  1657.                 table.remove(controlTable,12,deviceTable)
  1658.                 saveState(controlTable)
  1659.             else deviceTable.status = "false"
  1660.                 deviceTable.color = "false"
  1661.                 table.insert(controlTable,11,deviceTable)
  1662.                 table.remove(controlTable,12,deviceTable)
  1663.                 saveState(controlTable)
  1664.             end
  1665.             local deviceTable = {type="Extractor"}
  1666.             title()
  1667.             print("Would you like to control an IC2 Extractor?")
  1668.             extractor = yN()
  1669.             if extractor == "true" then
  1670.                 term.clear()
  1671.                 term.setCursorPos(1,9)
  1672.                 print("           What color are you using?")
  1673.                 sleep(1.5)
  1674.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1675.                 deviceTable.status = "false"
  1676.                 table.insert(controlTable,12,deviceTable)
  1677.                 table.remove(controlTable,13,deviceTable)
  1678.                 saveState(controlTable)
  1679.             else deviceTable.status = "false"
  1680.                 deviceTable.color = "false"
  1681.                 table.insert(controlTable,12,deviceTable)
  1682.                 table.remove(controlTable,13,deviceTable)
  1683.                 saveState(controlTable)
  1684.             end
  1685.         else
  1686.             modTable.color = "false"
  1687.             table.insert(controlTable,4,modTable)
  1688.             table.remove(controlTable,5,devicetable)
  1689.             saveState(controlTable)
  1690.         end
  1691.     elseif mods == 2 then  --RedPower2
  1692.         local modTable = {type="RedPower2"}
  1693.         modTable.status = "true"
  1694.         title()
  1695.         print("Do you want to control this mod?")
  1696.         local input = yN()
  1697.         if input == "true" then
  1698.             modTable.color = "true"
  1699.             table.insert(controlTable,13,modTable)
  1700.             table.remove(controlTable,14,modTable)
  1701.             saveState(controlTable)
  1702.             local deviceTable = {type="RedPowerPump"}
  1703.             title()
  1704.             print("Would you like to control a RedPower pump?")
  1705.             deviceTable.status = yN()
  1706.             if deviceTable.status == "true" then
  1707.                 term.clear()
  1708.                 term.setCursorPos(1,9)
  1709.                 print("           What color are you using?")
  1710.                 sleep(1.5)
  1711.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1712.                 deviceTable.status = "false"
  1713.                 table.insert(controlTable,14,deviceTable)
  1714.                 table.remove(controlTable,15,deviceTable)
  1715.                 saveState(controlTable)
  1716.             else deviceTable.status = "false"
  1717.                 deviceTable.color = "false"
  1718.                 table.insert(controlTable,14,deviceTable)
  1719.                 table.remove(controlTable,15,deviceTable)
  1720.                 saveState(controlTable)
  1721.             end
  1722.             local deviceTable = {type="Blockbreaker"}
  1723.             title()
  1724.             print("Would you like to control a RedPower Blockbreaker array?")
  1725.             deviceTable.status = yN()
  1726.             if deviceTable.status == "true" then
  1727.                 term.clear()
  1728.                 term.setCursorPos(1,9)
  1729.                 print("           What color are you using?")
  1730.                 sleep(1.5)
  1731.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1732.                 deviceTable.status = "false"
  1733.                 table.insert(controlTable,15,deviceTable)
  1734.                 table.remove(controlTable,16,deviceTable)
  1735.                 saveState(controlTable)
  1736.             else deviceTable.status = "false"
  1737.                 deviceTable.color = "false"
  1738.                 table.insert(controlTable,15,deviceTable)
  1739.                 table.remove(controlTable,16,deviceTable)
  1740.                 saveState(controlTable)
  1741.             end
  1742.         else
  1743.             modTable.color = "false"
  1744.             table.insert(controlTable,13,modTable)
  1745.             table.remove(controlTable,14,modTable)
  1746.             saveState(controlTable)
  1747.         end
  1748.     elseif mods == 3 then  --Buildcraft
  1749.         local modTable = {type="Buildcraft"}
  1750.         modTable.status = "true"
  1751.         title()
  1752.         print("Do you want to control this mod?")
  1753.         local input = yN()
  1754.         if input == "true" then
  1755.             modTable.color = "true"
  1756.             table.insert(controlTable,16,modTable)
  1757.             table.remove(controlTable,17,modTable)
  1758.             saveState(controlTable)
  1759.             --add for engines
  1760.             local deviceTable = {type="MiningWell"}
  1761.             title()
  1762.             print("Would you like to control a Mining Well?")
  1763.             deviceTable.status = yN()
  1764.             if deviceTable.status == "true" then
  1765.                 term.clear()
  1766.                 term.setCursorPos(1,9)
  1767.                 print("           What color are you using?")
  1768.                 sleep(1.5)
  1769.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1770.                 deviceTable.status = "false"
  1771.                 table.insert(controlTable,17,deviceTable)
  1772.                 table.remove(controlTable,18,deviceTable)
  1773.                 saveState(controlTable)
  1774.             else deviceTable.status = "false"
  1775.                 deviceTable.color = "false"
  1776.                 table.insert(controlTable,17,deviceTable)
  1777.                 table.remove(controlTable,18,deviceTable)
  1778.                 saveState(controlTable)
  1779.             end
  1780.             local deviceTable = {type="Quarry"}
  1781.             title()
  1782.             print("Would you like to control a Quarry?")
  1783.             deviceTable.status = yN()
  1784.             if deviceTable.status == "true" then
  1785.                 term.clear()
  1786.                 term.setCursorPos(1,9)
  1787.                 print("           What color are you using?")
  1788.                 sleep(1.5)
  1789.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1790.                 deviceTable.status = "false"
  1791.                 table.insert(controlTable,18,deviceTable)
  1792.                 table.remove(controlTable,19,deviceTable)
  1793.                 saveState(controlTable)
  1794.             else deviceTable.status = "false"
  1795.                 deviceTable.color = "false"
  1796.                 table.insert(controlTable,18,deviceTable)
  1797.                 table.remove(controlTable,19,deviceTable)
  1798.                 saveState(controlTable)
  1799.             end
  1800.             local deviceTable = {type="BuildcraftPump"}
  1801.             title()
  1802.             print("Would you like to control a Buildcraft pump?")
  1803.             deviceTable.status = yN()
  1804.             if deviceTable.status == "true" then
  1805.                 term.clear()
  1806.                 term.setCursorPos(1,9)
  1807.                 print("           What color are you using?")
  1808.                 sleep(1.5)
  1809.                 deviceTable.color = colorConvert(opt(colorOpt,0))
  1810.                 deviceTable.status = "false"
  1811.                 table.insert(controlTable,19,deviceTable)
  1812.                 table.remove(controlTable,20,deviceTable)
  1813.                 saveState(controlTable)
  1814.             else deviceTable.status = "false"
  1815.                 deviceTable.color = "false"
  1816.                 table.insert(controlTable,19,deviceTable)
  1817.                 table.remove(controlTable,20,deviceTable)
  1818.                 saveState(controlTable)
  1819.             end
  1820.         else
  1821.             modTable.color = "false"
  1822.             table.insert(controlTable,16,modTable)
  1823.             table.remove(controlTable,17,modTable)
  1824.             saveState(controlTable)
  1825.         end
  1826.     elseif mods == 4 then --Immibis' Forcefields
  1827.         local modTable = {type="Forcefield"}
  1828.         modTable.status = "true"
  1829.         title()
  1830.         print("Do you want to control this mod?")
  1831.         local input = yN()
  1832.         if input == "true" then
  1833.             modTable.color = "true"
  1834.             table.insert(controlTable,20,modTable)
  1835.             table.remove(controlTable,21,modTable)
  1836.             saveState(controlTable)
  1837.             title()
  1838.             print("           What color are you using?")
  1839.             sleep(2)
  1840.             deviceTable.color = colorConvert(opt(colorOpt,0))
  1841.             deviceTable.status = "false"
  1842.             table.insert(controlTable,21,deviceTable)
  1843.             table.remove(controlTable,22,deviceTable)
  1844.             saveState(controlTable)
  1845.         else
  1846.             modTable.color = "false"
  1847.             table.insert(controlTable,20,modTable)
  1848.             table.remove(controlTable,21,modTable)
  1849.             saveState(controlTable)
  1850.         end
  1851.     end
  1852. title()
  1853. print("Do you have any other Mods installed?")
  1854. local input = yN()
  1855.     if input == "false" then break end
  1856. end
  1857. local deviceTable = {type="Firstrun"}
  1858. deviceTable.color = "completed"
  1859. deviceTable.status = "true"
  1860. table.insert(controlTable,21,deviceTable)
  1861. saveState(controlTable)
  1862. term.clear()
  1863. term.setCursorPos(1,1)
  1864. textutils.slowPrint("Thank you. You will now be redirected.")
  1865. sleep(1.5)
  1866. end
  1867. local function toColor(c)
  1868.     if c == "false" then return "None"
  1869.     elseif c == "redstone" then return "Redstone"
  1870.     elseif c == "1" then return "White"
  1871.     elseif c == "2" then return "Orange"
  1872.     elseif c == "4" then return "Magenta"
  1873.     elseif c == "8" then return "Light Blue"
  1874.     elseif c == "16" then return "Yellow"
  1875.     elseif c == "32" then return "Lime"
  1876.     elseif c == "64" then return "Pink"
  1877.     elseif c == "128" then return "Gray"
  1878.     elseif c == "256" then return "Light Gray"
  1879.     elseif c == "512" then return "Cyan"
  1880.     elseif c == "1024" then return "Purple"
  1881.     elseif c == "2048" then return "Blue"
  1882.     elseif c == "4096" then return "Brown"
  1883.     elseif c == "8192" then return "Green"
  1884.     elseif c == "16384" then return "Red"
  1885.     elseif c == "32768" then return "Black"
  1886.     else return "test"
  1887.     end
  1888. end
  1889. local function systemScreen()
  1890. mainPage()
  1891. term.setCursorPos(1,6)
  1892. term.clearLine()
  1893. term.setCursorPos(1,4)
  1894. print("|                 System Status                 |")
  1895. print("+-----------------------------------------------+")
  1896. end
  1897. local function system()
  1898. local controlTable = loadState()
  1899. for dNum, dInfo in ipairs(controlTable) do
  1900.     if dInfo.type == "Admin" then
  1901.         systemScreen()
  1902.         textutils.slowWrite(dInfo.type)
  1903.         textutils.slowWrite(": ")
  1904.         sleep(.25)
  1905.         textutils.slowWrite(dInfo.color)
  1906.         textutils.slowWrite(", ")
  1907.         sleep(.25)
  1908.         textutils.slowPrint("*****")
  1909.         sleep(.25)
  1910.     elseif dInfo.type == "User" then
  1911.         textutils.slowWrite(dInfo.type)
  1912.         textutils.slowWrite(": ")
  1913.         sleep(.25)
  1914.         textutils.slowWrite(dInfo.color)
  1915.         textutils.slowWrite(", ")
  1916.         sleep(.25)
  1917.         textutils.slowPrint("*****")
  1918.         sleep(.25)
  1919.     elseif dInfo.type == "Firstrun" then
  1920.         systemScreen()
  1921.         textutils.slowWrite(dInfo.type)
  1922.         textutils.slowWrite(" ")
  1923.         sleep(.25)
  1924.         textutils.slowWrite(dInfo.color)
  1925.         textutils.slowWrite(": ")
  1926.         sleep(.25)
  1927.         textutils.slowPrint(dInfo.status)
  1928.     elseif dInfo.type == "IndustrialCraft2" or dInfo.type == "RedPower2" or dInfo.type == "Buildcraft" then
  1929.         systemScreen()
  1930.         textutils.slowWrite(dInfo.type)
  1931.         textutils.slowWrite(": ")
  1932.         sleep(.25)
  1933.         textutils.slowPrint(dInfo.status)
  1934.         sleep(.25)
  1935.     elseif dInfo.type == "Forcefield" then
  1936.         systemScreen()
  1937.         textutils.slowWrite(dInfo.type)
  1938.         textutils.slowWrite(": ")
  1939.         sleep(.25)
  1940.         textutils.slowWrite(toColor(dInfo.color))
  1941.         textutils.slowWrite(", ")
  1942.         sleep(.25)
  1943.         textutils.slowPrint(dInfo.status)
  1944.         sleep(.25)
  1945.     else
  1946.         textutils.slowWrite(dInfo.type)
  1947.         textutils.slowWrite(": ")
  1948.         sleep(.25)
  1949.         textutils.slowWrite(toColor(dInfo.color))
  1950.         textutils.slowWrite(", ")
  1951.         sleep(.25)
  1952.         textutils.slowPrint(dInfo.status)
  1953.         sleep(.25)
  1954.     end
  1955. end
  1956. while true do
  1957. term.setCursorPos(31,13)
  1958. write(".----------------.")
  1959. term.setCursorPos(31,14)
  1960. write("|   Press OK to  |")
  1961. term.setCursorPos(31,15)
  1962. write("|     continue   |")
  1963. term.setCursorPos(31,16)
  1964. write("|                |")
  1965. term.setCursorPos(31,17)
  1966. write("+------[OK]------+")
  1967. event, p1 = os.pullEvent("key")
  1968. if p1 == 28 then
  1969.     break
  1970. end
  1971. end
  1972. end
  1973. local function resume()
  1974. controlTable = loadState()
  1975. local colorVar = 0
  1976. for eNum, dInfo in ipairs(controlTable) do
  1977.     for i = 1,#machineList do
  1978.         if dInfo.type == machineList[i] then
  1979.             if dInfo.type == "Reactor" or dInfo.type == "Coolant" then
  1980.                 if dInfo.status == "false" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
  1981.                     colorVar = colorVar + tonumber(dInfo.color)
  1982.                 elseif dInfo.status == "true" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
  1983.                     colorVar = colorVar + 0
  1984.                 end
  1985.             else
  1986.                 if dInfo.status == "false" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
  1987.                     colorVar = colorVar + 0
  1988.                 elseif dInfo.status == "true" and dInfo.color ~= "false" and dInfo.color ~= "true" and dInfo.color ~= "redstone" then
  1989.                     colorVar = colorVar + tonumber(dInfo.color)
  1990.                 end
  1991.             end
  1992.         end
  1993.     end
  1994. end
  1995. rs.setBundledOutput("back",colorVar)
  1996. end
  1997. --monitor actions
  1998. local function MCscreen()
  1999. if pM then
  2000. local mX,mY = mon.getSize()
  2001. mon.clear()
  2002. mon.setCursorPos(1,1)
  2003. for i=1,mX do
  2004.     mon.setCursorPos(i,1)
  2005.     mon.write("-")
  2006.     mon.setCursorPos(i,mY)
  2007.     mon.write("-")
  2008.     mon.setCursorPos(i,5)
  2009.     mon.write("-")
  2010.     mon.setCursorPos(i,7)
  2011.     mon.write("-")
  2012. end
  2013. for i=1,mY do
  2014.     mon.setCursorPos(1,i)
  2015.     mon.write("|")
  2016.     mon.setCursorPos(mX,i)
  2017.     mon.write("|")
  2018. end
  2019. for i=6,mY-1 do
  2020.     mon.setCursorPos(25,i)
  2021.     mon.write("|")
  2022.     mon.setCursorPos(50,i)
  2023.     mon.write("|")
  2024. end
  2025. for i=2,mX do
  2026.     mon.setCursorPos(i,16)
  2027.     mon.write("-")
  2028.     mon.setCursorPos(i,18)
  2029.     mon.write("-")
  2030. end
  2031. mon.setCursorPos(1,1)
  2032. mon.write(".")
  2033. mon.setCursorPos(mX,1)
  2034. mon.write(".")
  2035. mon.setCursorPos(1,5)
  2036. mon.write("+")
  2037. mon.setCursorPos(mX,5)
  2038. mon.write("+")
  2039. mon.setCursorPos(1,7)
  2040. mon.write("+")
  2041. mon.setCursorPos(mX,7)
  2042. mon.write("+")
  2043. mon.setCursorPos(1,mY)
  2044. mon.write("'")
  2045. mon.setCursorPos(mX,mY)
  2046. mon.write("'")
  2047. mon.setCursorPos(25,5)
  2048. mon.write("+")
  2049. mon.setCursorPos(50,5)
  2050. mon.write("+")
  2051. mon.setCursorPos(25,7)
  2052. mon.write("+")
  2053. mon.setCursorPos(50,7)
  2054. mon.write("+")
  2055. mon.setCursorPos(25,mY)
  2056. mon.write("+")
  2057. mon.setCursorPos(50,mY)
  2058. mon.write("+")
  2059. mon.setCursorPos(1,16)
  2060. mon.write("+")
  2061. mon.setCursorPos(mX,16)
  2062. mon.write("+")
  2063. mon.setCursorPos(25,16)
  2064. mon.write("+")
  2065. mon.setCursorPos(50,16)
  2066. mon.write("+")
  2067. mon.setCursorPos(1,18)
  2068. mon.write("+")
  2069. mon.setCursorPos(mX,18)
  2070. mon.write("+")
  2071. mon.setCursorPos(25,18)
  2072. mon.write("+")
  2073. mon.setCursorPos(50,18)
  2074. mon.write("+")
  2075. local b = string.len("Master Control System Status")/2
  2076. local x = (mX/2)-b
  2077. mon.setCursorPos(x,3)
  2078. mon.write("Master Control System Status")
  2079. end
  2080. end
  2081. local function mStatus(x)
  2082. local controlTable = loadState()
  2083. if x=="true" then state="On"
  2084. elseif x=="false" then state="Off"
  2085. end
  2086. return state
  2087. end
  2088. local function monTitle()
  2089. while true do
  2090. mon.clear()
  2091. MCscreen()
  2092. local controlTable = loadState()
  2093. for eNum,dInfo in ipairs(controlTable) do
  2094.     if dInfo.type~="Admin" and dInfo.type~="User" and dInfo.type~="Firstrun" then
  2095.         mon.setCursorPos(5,6)
  2096.         mon.write("IndustrialCraft")
  2097.         if dInfo.type=="Macerator" then
  2098.             mon.setCursorPos(3,8)
  2099.             mon.write("Macerator: ")
  2100.             mon.write(mStatus(dInfo.status))
  2101.         elseif dInfo.type=="Furnace" then
  2102.             mon.setCursorPos(3,10)
  2103.             mon.write("Furnace: ")
  2104.             mon.write(mStatus(dInfo.status))
  2105.         elseif dInfo.type=="Compressor" then
  2106.             mon.setCursorPos(3,12)
  2107.             mon.write("Compressor: ")
  2108.             mon.write(mStatus(dInfo.status))
  2109.         elseif dInfo.type=="Extractor" then
  2110.             mon.setCursorPos(3,14)
  2111.             mon.write("Extractor: ")
  2112.             mon.write(mStatus(dInfo.status))
  2113.         end
  2114.         mon.setCursorPos(33,6)
  2115.         mon.write("Buildcraft")
  2116.         if dInfo.type == "MiningWell" then
  2117.             mon.setCursorPos(27,8)
  2118.             mon.write("Mining Well: ")
  2119.             mon.write(mStatus(dInfo.status))
  2120.         elseif dInfo.type == "Quarry" then
  2121.             mon.setCursorPos(27,10)
  2122.             mon.write("Quarry: ")
  2123.             mon.write(mStatus(dInfo.status))
  2124.         elseif dInfo.type == "BuildcraftPump" then
  2125.             mon.setCursorPos(27,12)
  2126.             mon.write("BC2 Pump: ")
  2127.             mon.write(mStatus(dInfo.status))
  2128.         end
  2129.         mon.setCursorPos(59,6)
  2130.         mon.write("RedPower")
  2131.         if dInfo.type == "RedPowerPump" then
  2132.             mon.setCursorPos(52,8)
  2133.             mon.write("RedPower Pump: ")
  2134.             mon.write(mStatus(dInfo.status))
  2135.         elseif dInfo.type == "Blockbreaker" then
  2136.             mon.setCursorPos(52,10)
  2137.             mon.write("Blockbreakers: ")
  2138.             mon.write(mStatus(dInfo.status))
  2139.         end
  2140.         mon.setCursorPos(2,17)
  2141.         mon.write("IndustrialCraft Power")
  2142.         if dInfo.type=="MFSU" or dInfo.type == "Batbox" or dInfo.type == "MFE"then
  2143.             mon.setCursorPos(3,19)
  2144.             mon.write(dInfo.type..": ")
  2145.             mon.write(dInfo.status)
  2146.         elseif dInfo.type=="Reactor" and dInfo.color~="false" then
  2147.             mon.setCursorPos(3,23)
  2148.             mon.write("Reactor: ")
  2149.             mon.write(mStatus(dInfo.status))
  2150.             mon.setCursorPos(3,25)
  2151.             mon.write("Coolant: ")
  2152.             mon.write(mStatus(dInfo.status))
  2153.         end
  2154.         mon.setCursorPos(30,17)
  2155.         mon.write("Buildcraft Power")
  2156.         for i = 1,#BCpower do
  2157.             if dInfo.type == pTypeX[i] then
  2158.                 mon.setCursorPos(27,19)
  2159.                 mon.write(dInfo.type..": ")
  2160.                 mon.write(mStatus(dInfo.status))
  2161.             end
  2162.         end
  2163.         mon.setCursorPos(57,17)
  2164.         mon.write("Forcefield")
  2165.         if dInfo.type == "Forcefield" then
  2166.             mon.setCursorPos(52,19)
  2167.             mon.write("Forcefield: ")
  2168.             mon.write(mStatus(dInfo.status))
  2169.         end
  2170.     end
  2171. end
  2172. sleep(1)
  2173. end
  2174. end
  2175. local function MCtime()
  2176. while pM do
  2177. local mX,mY = mon.getSize()
  2178.     local t = os.time()
  2179.     time = textutils.formatTime(t,false)
  2180.     mon.setCursorPos(mX-9,3)
  2181.     mon.write(time)
  2182.     sleep(0)
  2183. end
  2184. end
  2185. --main code
  2186. local function MCS()
  2187. if not fs.exists("status") then
  2188.     term.clear()
  2189.     firstRun()
  2190. end
  2191. local user,pass = login()
  2192. while true do
  2193. newPage()
  2194. resume()
  2195. controlTable = loadState()
  2196. for eNum, dInfo in ipairs(controlTable) do
  2197.     if dInfo.type == "Firstrun" then
  2198.         if dInfo.status == "false" then
  2199.             firstRun()
  2200.         elseif dInfo.status == nil then
  2201.             firstRun()
  2202.         end
  2203.     end
  2204. end
  2205. local option = menuOpt()
  2206.     if option == "1" then --production started
  2207.         while true do
  2208.             prodPage()
  2209.             local input = opt(pMenu,5)
  2210.             if input == 1 then
  2211.                 controlTable = loadState()
  2212.                 for dNum, deviceTable in ipairs(controlTable) do
  2213.                     if deviceTable.type == "Macerator" then
  2214.                         if deviceTable.status == "false" then
  2215.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2216.                             deviceTable.status = "true"
  2217.                             table.insert(controlTable,9,deviceTable)
  2218.                             table.remove(controlTable,10,deviceTable)
  2219.                             saveState(controlTable)
  2220.                         elseif deviceTable.status == "true" then
  2221.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2222.                             deviceTable.status = "false"
  2223.                             table.insert(controlTable,9,deviceTable)
  2224.                             table.remove(controlTable,10,deviceTable)
  2225.                             saveState(controlTable)
  2226.                         end
  2227.                     end
  2228.                 end
  2229.             elseif input == 2 then
  2230.                 controlTable = loadState()
  2231.                 for dNum, deviceTable in ipairs(controlTable) do
  2232.                     if deviceTable.type == "Furnace" then
  2233.                         if deviceTable.status == "false" then
  2234.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2235.                             deviceTable.status = "true"
  2236.                             table.insert(controlTable,10,deviceTable)
  2237.                             table.remove(controlTable,11,deviceTable)
  2238.                             saveState(controlTable)
  2239.                         elseif deviceTable.status == "true" then
  2240.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2241.                             deviceTable.status = "false"
  2242.                             table.insert(controlTable,10,deviceTable)
  2243.                             table.remove(controlTable,11,deviceTable)
  2244.                             saveState(controlTable)
  2245.                         end
  2246.                     end
  2247.                 end
  2248.             elseif input == 3 then
  2249.                 controlTable = loadState()
  2250.                 for dNum, deviceTable in ipairs(controlTable) do
  2251.                     if deviceTable.type == "Compressor" then
  2252.                         if deviceTable.status == "false" then
  2253.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2254.                             deviceTable.status = "true"
  2255.                             table.insert(controlTable,11,deviceTable)
  2256.                             table.remove(controlTable,12,deviceTable)
  2257.                             saveState(controlTable)
  2258.                         elseif deviceTable.status == "true" then
  2259.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2260.                             deviceTable.status = "false"
  2261.                             table.insert(controlTable,11,deviceTable)
  2262.                             table.remove(controlTable,12,deviceTable)
  2263.                             saveState(controlTable)
  2264.                         end
  2265.                     end
  2266.                 end
  2267.             elseif input == 4 then
  2268.                 controlTable = loadState()
  2269.                 for dNum, deviceTable in ipairs(controlTable) do
  2270.                     if deviceTable.type == "Extractor" then
  2271.                         if deviceTable.status == "false" then
  2272.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2273.                             deviceTable.status = "true"
  2274.                             table.insert(controlTable,12,deviceTable)
  2275.                             table.remove(controlTable,13,deviceTable)
  2276.                             saveState(controlTable)
  2277.                         elseif deviceTable.status == "true" then
  2278.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2279.                             deviceTable.status = "false"
  2280.                             table.insert(controlTable,12,deviceTable)
  2281.                             table.remove(controlTable,13,deviceTable)
  2282.                             saveState(controlTable)
  2283.                         end
  2284.                     end
  2285.                 end
  2286.             elseif input == 5 then
  2287.                 controlTable = loadState()
  2288.                 for dNum, deviceTable in ipairs(controlTable) do
  2289.                     if deviceTable.type == "RedPowerPump" then
  2290.                         if deviceTable.status == "false" then
  2291.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2292.                             deviceTable.status = "true"
  2293.                             table.insert(controlTable,14,deviceTable)
  2294.                             table.remove(controlTable,15,deviceTable)
  2295.                             saveState(controlTable)
  2296.                         elseif deviceTable.status == "true" then
  2297.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2298.                             deviceTable.status = "false"
  2299.                             table.insert(controlTable,14,deviceTable)
  2300.                             table.remove(controlTable,15,deviceTable)
  2301.                             saveState(controlTable)
  2302.                         end
  2303.                     end
  2304.                 end
  2305.             elseif input == 6 then
  2306.                 controlTable = loadState()
  2307.                 for dNum, deviceTable in ipairs(controlTable) do
  2308.                     if deviceTable.type == "Blockbreaker" then
  2309.                         if deviceTable.status == "false" then
  2310.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2311.                             deviceTable.status = "true"
  2312.                             table.insert(controlTable,15,deviceTable)
  2313.                             table.remove(controlTable,16,deviceTable)
  2314.                             saveState(controlTable)
  2315.                         elseif deviceTable.status == "true" then
  2316.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2317.                             deviceTable.status = "false"
  2318.                             table.insert(controlTable,15,deviceTable)
  2319.                             table.remove(controlTable,16,deviceTable)
  2320.                             saveState(controlTable)
  2321.                         end
  2322.                     end
  2323.                 end
  2324.             elseif input == 7 then
  2325.                 controlTable = loadState()
  2326.                 for dNum, deviceTable in ipairs(controlTable) do
  2327.                     if deviceTable.type == "MiningWell" then
  2328.                         if deviceTable.status == "false" then
  2329.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2330.                             deviceTable.status = "true"
  2331.                             table.insert(controlTable,17,deviceTable)
  2332.                             table.remove(controlTable,18,deviceTable)
  2333.                             saveState(controlTable)
  2334.                         elseif deviceTable.status == "true" then
  2335.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2336.                             deviceTable.status = "false"
  2337.                             table.insert(controlTable,17,deviceTable)
  2338.                             table.remove(controlTable,18,deviceTable)
  2339.                             saveState(controlTable)
  2340.                         end
  2341.                     end
  2342.                 end
  2343.             elseif input == 8 then
  2344.                 controlTable = loadState()
  2345.                 for dNum, deviceTable in ipairs(controlTable) do
  2346.                     if deviceTable.type == "Quarry" then
  2347.                         if deviceTable.status == "false" then
  2348.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2349.                             deviceTable.status = "true"
  2350.                             table.insert(controlTable,18,deviceTable)
  2351.                             table.remove(controlTable,19,deviceTable)
  2352.                             saveState(controlTable)
  2353.                         elseif deviceTable.status == "true" then
  2354.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2355.                             deviceTable.status = "false"
  2356.                             table.insert(controlTable,18,deviceTable)
  2357.                             table.remove(controlTable,19,deviceTable)
  2358.                             saveState(controlTable)
  2359.                         end
  2360.                     end
  2361.                 end
  2362.             elseif input == 9 then
  2363.                 controlTable = loadState()
  2364.                 for dNum, deviceTable in ipairs(controlTable) do
  2365.                     if deviceTable.type == "BuildcraftPump" then
  2366.                         if deviceTable.status == "false" then
  2367.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2368.                             deviceTable.status = "true"
  2369.                             table.insert(controlTable,19,deviceTable)
  2370.                             table.remove(controlTable,20,deviceTable)
  2371.                             saveState(controlTable)
  2372.                         elseif deviceTable.status == "true" then
  2373.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2374.                             deviceTable.status = "false"
  2375.                             table.insert(controlTable,19,deviceTable)
  2376.                             table.remove(controlTable,20,deviceTable)
  2377.                             saveState(controlTable)
  2378.                         end
  2379.                     end
  2380.                 end
  2381.             elseif input == 10 then
  2382.                 controlTable = loadState()
  2383.                 for dNum, deviceTable in ipairs(controlTable) do
  2384.                     if deviceTable.type == "Forcefield" then
  2385.                         if deviceTable.status == "false" then
  2386.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2387.                             deviceTable.status = "true"
  2388.                             table.insert(controlTable,20,deviceTable)
  2389.                             table.remove(controlTable,21,deviceTable)
  2390.                             saveState(controlTable)
  2391.                         elseif deviceTable.status == "true" then
  2392.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2393.                             deviceTable.status = "false"
  2394.                             table.insert(controlTable,20,deviceTable)
  2395.                             table.remove(controlTable,21,deviceTable)
  2396.                             saveState(controlTable)
  2397.                         end
  2398.                     end
  2399.                 end
  2400.             elseif input == 11 then break  
  2401.             end
  2402.         end
  2403.     elseif option == "2" then --reactor control
  2404.         if user == admin and pass == true then
  2405.         while true do
  2406.         nukePage()
  2407.         local input = opt(rMenu,7)
  2408.             if input == 1 then
  2409.                 controlTable = loadState()
  2410.                 for dNum, deviceTable in ipairs(controlTable) do
  2411.                     if deviceTable.type == "Reactor" then
  2412.                         if deviceTable.status == "false" then
  2413.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2414.                             deviceTable.status = "true"
  2415.                             table.insert(controlTable,6,deviceTable)
  2416.                             table.remove(controlTable,7,deviceTable)
  2417.                             saveState(controlTable)
  2418.                         end
  2419.                     elseif deviceTable.type == "Coolant" then
  2420.                         if deviceTable.status == "false" then
  2421.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2422.                             deviceTable.status = "true"
  2423.                             table.insert(controlTable,7,deviceTable)
  2424.                             table.remove(controlTable,8,deviceTable)
  2425.                             saveState(controlTable)
  2426.                         end
  2427.                     end
  2428.                 end
  2429.             elseif input == 2 then
  2430.                 controlTable = loadState()
  2431.                 for dNum, deviceTable in ipairs(controlTable) do
  2432.                     if deviceTable.type == "Reactor" then
  2433.                         if deviceTable.status == "true" then
  2434.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2435.                             deviceTable.status = "false"
  2436.                             table.insert(controlTable,6,deviceTable)
  2437.                             table.remove(controlTable,7,deviceTable)
  2438.                             saveState(controlTable)
  2439.                         end
  2440.                     elseif deviceTable.type == "Coolant" then
  2441.                         if deviceTable.status == "true" then
  2442.                             rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2443.                             deviceTable.status = "false"
  2444.                             table.insert(controlTable,7,deviceTable)
  2445.                             table.remove(controlTable,8,deviceTable)
  2446.                             saveState(controlTable)
  2447.                         end
  2448.                     end
  2449.                 end
  2450.             elseif input == 3 then break
  2451.             end
  2452.         end
  2453.         else
  2454.             term.clear()
  2455.             term.setCursorPos(1,10)
  2456.             print("   You must be Admin level to use the reactor    ")
  2457.             sleep(1)
  2458.         end
  2459.     elseif option == "3" then --lights
  2460.         controlTable = loadState()
  2461.         for dNum, deviceTable in ipairs(controlTable) do
  2462.             if deviceTable.type == "Lights" then
  2463.                 if deviceTable.status == "true" then
  2464.                     rs.setBundledOutput("back", colors.subtract(tonumber(deviceTable.color)))
  2465.                     deviceTable.status = "false"
  2466.                     table.insert(controlTable,3,deviceTable)
  2467.                     table.remove(controlTable,4,deviceTable)
  2468.                     saveState(controlTable)
  2469.                 elseif deviceTable.status == "false" then
  2470.                     rs.setBundledOutput("back", colors.combine(tonumber(deviceTable.color)))
  2471.                     deviceTable.status = "true"
  2472.                     table.insert(controlTable,3,deviceTable)
  2473.                     table.remove(controlTable,4,deviceTable)
  2474.                     saveState(controlTable)
  2475.                 end break
  2476.             end
  2477.         end
  2478.     elseif option == "4" then --maintenance
  2479.         while true do
  2480.         mainPage()
  2481.         local input = opt(mMenu,7)
  2482.             if input == 1 then
  2483.                 system()
  2484.             elseif input == 2 then
  2485.                 if user == admin and pass == true then
  2486.                 local controlTable = loadState()
  2487.                     firstRun()
  2488.                 else
  2489.                     term.clear()
  2490.                     term.setCursorPos(1,10)
  2491.                     print("  You must be Admin level to run Initialization  ")
  2492.                     sleep(1.5)
  2493.                 end
  2494.             elseif input == 3 then break
  2495.             end
  2496.         end
  2497.     elseif option == "5" then --games
  2498.         games()
  2499.     elseif option == "6" then os.shutdown()
  2500.     end
  2501. end
  2502. end
  2503. --parallel
  2504. if pM then
  2505. parallel.waitForAll(MCS,monTitle,MCtime)
  2506. else
  2507. MCS()
  2508. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement