Advertisement
Aest47

Untitled

Aug 31st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.77 KB | None | 0 0
  1. --Hardware Variables---------------------------------------
  2. local cm1 = peripheral.wrap("monitor_25")
  3.  
  4. local rm1 = peripheral.wrap("monitor_58")
  5. local rm2 = peripheral.wrap("monitor_59")
  6. local rm3 = peripheral.wrap("monitor_60")
  7.  
  8. local tm1 = peripheral.wrap("monitor_3")
  9. local tm2 = peripheral.wrap("monitor_23")
  10. local tm3 = peripheral.wrap("monitor_22")
  11.  
  12. local r1 = peripheral.wrap("BigReactors-Reactor_2")
  13. local t1 = peripheral.wrap("BigReactors-Turbine_13")
  14. local t2 = peripheral.wrap("BigReactors-Turbine_14")
  15. local t3 = peripheral.wrap("BigReactors-Turbine_15")
  16.  
  17. --Button Toggle variables-----------------------------------
  18. local r1auto = true
  19. local t1auto = true
  20. local t2auto = true
  21. local t3auto = true
  22.  
  23. --Control Button Toggle ------------------------------------
  24. function btn(y,state)
  25.  
  26. if state == "on" then
  27. cm1.setCursorPos(18,y)
  28. cm1.setBackgroundColor(colors.green)
  29. cm1.write(" ON ")
  30. cm1.setCursorPos(25,y)
  31. cm1.setBackgroundColor(colors.gray)
  32. cm1.write(" OFF ")
  33. cm1.setBackgroundColor(colors.black)
  34.  
  35. if y == 1 then
  36. r1auto = true
  37.  
  38. elseif y == 2 then
  39. t1auto = true
  40.  
  41. elseif y == 3 then
  42. t2auto = true
  43.  
  44. elseif y == 4 then
  45. t3auto = true
  46.  
  47. end
  48.  
  49. elseif state == "off" then
  50. cm1.setCursorPos(18,y)
  51. cm1.setBackgroundColor(colors.gray)
  52. cm1.write(" ON ")
  53. cm1.setCursorPos(25,y)
  54. cm1.setBackgroundColor(colors.red)
  55. cm1.write(" OFF ")
  56. cm1.setBackgroundColor(colors.black)
  57.  
  58. if y == 1 then
  59. r1auto = false
  60.  
  61. elseif y == 2 then
  62. t1auto = false
  63.  
  64. elseif y == 3 then
  65. t2auto = false
  66.  
  67. elseif y == 4 then
  68. t3auto = false
  69.  
  70. end
  71.  
  72. end
  73.  
  74. end
  75.  
  76. --Start Program--------------------------------------------------
  77. print("Running ReactorOS..")
  78.  
  79. --Control panel initialize----------------------------------------
  80. cm1.setBackgroundColor(colors.black)
  81. cm1.clear()
  82.  
  83. --Reactor
  84. cm1.setCursorPos(1,1)
  85. cm1.write("Reactor")
  86. btn(1,"on")
  87. r1.setActive(true)
  88. r1.setAllControlRodLevels(100)
  89.  
  90. --Turbine 1
  91. cm1.setCursorPos(1,2)
  92. cm1.write("Turbine 1")
  93. btn(2,"on")
  94. t1.setActive(true)
  95.  
  96. --Turbine 2
  97. cm1.setCursorPos(1,3)
  98. cm1.write("Turbine 2")
  99. btn(3,"on")
  100. t2.setActive(true)
  101.  
  102. --Turbine 3
  103. cm1.setCursorPos(1,4)
  104. cm1.write("Turbine 3")
  105. btn(4,"on")
  106. t3.setActive(true)
  107.  
  108. --Blast door
  109. cm1.setCursorPos(1,5)
  110. cm1.write("Blast Door")
  111. btn(5,"off")
  112. redstone.setOutput("top",false)
  113.  
  114. --Program Loop----------------------------------------------------
  115. while true do
  116.  
  117. --Reactor monitor 1 status display------------------------------------------------
  118.  
  119. rm1.setBackgroundColor(colors.black)
  120. rm1.setTextColor(colors.white)
  121. rm1.clear()
  122.  
  123. rm1.setTextColor(colors.white)
  124. rm1.setCursorPos(1,1)
  125. rm1.write("Reactor Core")
  126.  
  127. --Status-----------------------
  128. rm1.setCursorPos(15,1)
  129. rm1.write("Status:")
  130. rm1.setCursorPos(23,1)
  131.  
  132. if r1.getActive() == true then
  133. rm1.setTextColor(colors.green)
  134. rm1.write("ONLINE")
  135.  
  136. else
  137. rm1.setTextColor(colors.red)
  138. rm1.write("OFFLINE")
  139.  
  140. end
  141.  
  142. --reactivity-------------------
  143. local r1reactivity = math.floor(r1.getFuelReactivity())
  144.  
  145. rm1.setTextColor(colors.white)
  146. rm1.setCursorPos(1,3)
  147. rm1.write("Reactivity:")
  148.  
  149. --adjust cursor
  150. if r1reactivity == 100 then
  151. rm1.setCursorPos(18,3)
  152.  
  153. elseif r1reactivity >= 10 then
  154. rm1.setCursorPos(19,3)
  155.  
  156. elseif r1reactivity < 10 then
  157. rm1.setCursorPos(20,3)
  158.  
  159. end
  160.  
  161. rm1.setTextColor(colors.white)
  162. rm1.write(r1reactivity)
  163. rm1.setCursorPos(25,3)
  164. rm1.write(" %")
  165.  
  166.  
  167. --Reactor monitor 2 temp/rod/fuel rate display------------------------------------------------
  168.  
  169. --Temp------------------------------------------
  170. local temp = math.floor(r1.getFuelTemperature())
  171.  
  172. rm2.setBackgroundColor(colors.black)
  173. rm2.setTextColor(colors.white)
  174. rm2.clear()
  175.  
  176. rm2.setCursorPos(1,1)
  177. rm2.write("Reactor Control")
  178.  
  179. rm2.setTextColor(colors.white)
  180. rm2.setCursorPos(1,3)
  181. rm2.write("Temp:")
  182.  
  183. --color coding
  184. if temp >= 2000 then
  185. rm2.setTextColor(colors.red)
  186.  
  187. elseif temp >= 1500 then
  188. rm2.setTextColor(colors.orange)
  189.  
  190. elseif temp >= 1000 then
  191. rm2.setTextColor(colors.yellow)
  192.  
  193. elseif (temp < 1000) and (temp >= 500) then
  194. rm2.setTextColor(colors.green)
  195.  
  196. elseif temp < 500 then
  197. rm2.setTextColor(colors.cyan)
  198. end
  199.  
  200. --adjust cursor
  201. if temp >= 1000 then
  202. rm2.setCursorPos(19,3)
  203.  
  204. elseif (temp < 1000) and (temp >= 100) then
  205. rm2.setCursorPos(20,3)
  206.  
  207. elseif (temp < 100) and (temp >= 10) then
  208. rm2.setCursorPos(21,3)
  209.  
  210. elseif temp < 10 then
  211. rm2.setCursorPos(22,3)
  212.  
  213. end
  214.  
  215. rm2.write(temp)
  216.  
  217. rm2.setTextColor(colors.white)
  218. rm2.setCursorPos(25,3)
  219. rm2.write(" C")
  220.  
  221. --Rods-------------------------------
  222. local rods = r1.getControlRodLevel(0)
  223.  
  224. rm2.setTextColor(colors.white)
  225. rm2.setCursorPos(1,4)
  226. rm2.write("Output:")
  227.  
  228. --adjust cursor
  229. if (100 - rods) >= 10 then
  230. rm2.setCursorPos(23,4)
  231.  
  232. elseif (100 - rods) < 10 then
  233. rm2.setCursorPos(24,4)
  234.  
  235. end
  236.  
  237. rm2.setTextColor(colors.white)
  238. rm2.write(100 - rods)
  239. rm2.setCursorPos(25,4)
  240. rm2.write(" %")
  241.  
  242. --Fuel Rate------------------------------------
  243. local r1fuelrate = r1.getFuelConsumedLastTick()
  244. rm2.setTextColor(colors.white)
  245. rm2.setCursorPos(1,5)
  246. rm2.write("Fuel Rate:")
  247.  
  248. if r1fuelrate > 0 then
  249. rm2.setCursorPos(19,5)
  250.  
  251. else
  252. rm2.setCursorPos(22,5)
  253.  
  254. end
  255.  
  256. rm2.write(r1fuelrate)
  257.  
  258. rm2.setCursorPos(25,5)
  259. rm2.write(" MB/T")
  260.  
  261. --Reactor monitor 3 water/steam/steam rate display------------------------------------------------------
  262.  
  263. rm3.setBackgroundColor(colors.black)
  264. rm3.setTextColor(colors.white)
  265. rm3.clear()
  266.  
  267. rm3.setCursorPos(1,1)
  268. rm3.write("Reactor Coolant")
  269.  
  270. --Coolant amount----------------------------
  271. local r1waterlvl = r1.getCoolantAmount()
  272. local r1waterper = math.floor((r1waterlvl / 21800) * 100)
  273.  
  274. rm3.setTextColor(colors.white)
  275. rm3.setCursorPos(1,3)
  276. rm3.write("Coolant:")
  277.  
  278. --adjust cursor
  279. if r1waterper == 100 then
  280. rm3.setCursorPos(20,3)
  281.  
  282. elseif r1waterper >= 10 then
  283. rm3.setCursorPos(21,3)
  284.  
  285. elseif r1waterper < 10 then
  286. rm3.setCursorPos(22,3)
  287.  
  288. end
  289.  
  290. rm3.setTextColor(colors.white)
  291. rm3.write(r1waterper)
  292. rm3.setCursorPos(25,3)
  293. rm3.write(" %")
  294.  
  295. --Steam amount------------------------------
  296. local r1steamlvl = r1.getHotFluidAmount()
  297. local r1steamper = math.floor((r1steamlvl / 21800) * 100)
  298.  
  299. rm3.setTextColor(colors.white)
  300. rm3.setCursorPos(1,4)
  301. rm3.write("Steam:")
  302.  
  303. --adjust cursor
  304. if r1steamper == 100 then
  305. rm3.setCursorPos(20,4)
  306.  
  307. elseif r1steamper >= 10 then
  308. rm3.setCursorPos(21,4)
  309.  
  310. elseif r1steamper < 10 then
  311. rm3.setCursorPos(22,4)
  312.  
  313. end
  314.  
  315. rm3.setTextColor(colors.white)
  316. rm3.write(r1steamper)
  317. rm3.setCursorPos(25,4)
  318. rm3.write(" %")
  319.  
  320. --Steam Gen---------------------------------
  321. local r1steam = math.floor(r1.getHotFluidProducedLastTick())
  322.  
  323. rm3.setTextColor(colors.white)
  324. rm3.setCursorPos(1,5)
  325. rm3.write("Steam Gen:")
  326.  
  327. --adjust cursor----
  328. if r1steam >= 1000 then
  329. rm3.setCursorPos(19,5)
  330.  
  331. elseif (r1steam < 1000) and (r1steam >= 100) then
  332. rm3.setCursorPos(20,5)
  333.  
  334. elseif (r1steam < 100) and (r1steam >= 10) then
  335. rm3.setCursorPos(21,5)
  336.  
  337. elseif r1steam < 10 then
  338. rm3.setCursorPos(22,5)
  339.  
  340. end
  341.  
  342. rm3.setTextColor(colors.white)
  343. rm3.write(r1steam)
  344. rm3.setCursorPos(25,5)
  345. rm3.write(" MB/T")
  346.  
  347.  
  348. --Turbine 1 display----------------------------------------------------
  349. tm1.clear()
  350.  
  351. tm1.setTextColor(colors.white)
  352. tm1.setCursorPos(1,1)
  353. tm1.write("Turbine 1")
  354.  
  355. --status----
  356. tm1.setCursorPos(14,1)
  357. tm1.write("Status:")
  358. tm1.setCursorPos(22,1)
  359.  
  360. if t1.getActive() == true then
  361. tm1.setTextColor(colors.green)
  362. tm1.write("ONLINE")
  363.  
  364. else
  365. tm1.setTextColor(colors.red)
  366. tm1.write("OFFLINE")
  367.  
  368. end
  369.  
  370. --coils----
  371. tm1.setTextColor(colors.white)
  372. tm1.setCursorPos(15,3)
  373. tm1.write("Coils:")
  374. tm1.setCursorPos(22,3)
  375.  
  376. if t1.getInductorEngaged() == true then
  377. tm1.setTextColor(colors.green)
  378. tm1.write("ACTIVE")
  379. else
  380. tm1.setTextColor(colors.red)
  381. tm1.write("INACTIVE")
  382. end
  383.  
  384. --Percent capacitor filled----
  385. local t1per = math.floor((t1.getEnergyStored() / 1000000) * 100)
  386.  
  387. tm1.setTextColor(colors.white)
  388. tm1.setCursorPos(1,5)
  389. tm1.write("Power:")
  390.  
  391. --color coding
  392. if t1per >= 75 then
  393. tm1.setTextColor(colors.green)
  394.  
  395. elseif (t1per < 75) and (t1per >= 50) then
  396. tm1.setTextColor(colors.yellow)
  397.  
  398. elseif (t1per <50) and (t1per >= 25) then
  399. tm1.setTextColor(colors.orange)
  400.  
  401. elseif t1per < 25 then
  402. tm1.setTextColor(colors.red)
  403.  
  404. end
  405.  
  406. --adjust cursor
  407. if t1per >= 100 then
  408. tm1.setCursorPos(20,5)
  409.  
  410. elseif (t1per < 100) and (t1per >= 10) then
  411. tm1.setCursorPos(21,5)
  412.  
  413. elseif t1per < 10 then
  414. tm1.setCursorPos(22,5)
  415.  
  416. end
  417.  
  418. tm1.write(t1per)
  419.  
  420. tm1.setTextColor(colors.white)
  421. tm1.setCursorPos(25,5)
  422. tm1.write(" %")
  423.  
  424. --Power output----
  425. local t1powertick = t1.getEnergyProducedLastTick()
  426.  
  427. tm1.setTextColor(colors.white)
  428. tm1.setCursorPos(1,7)
  429. tm1.write("Rate:")
  430.  
  431. if t1powertick >= 10000 then
  432. tm1.setCursorPos(18,7)
  433.  
  434. elseif (t1powertick < 10000) and (t1powertick >= 1000) then
  435. tm1.setCursorPos(19,7)
  436.  
  437. elseif (t1powertick < 1000) and (t1powertick >= 100) then
  438. tm1.setCursorPos(20,7)
  439.  
  440. elseif (t1powertick < 100) and (t1powertick >= 10) then
  441. tm1.setCursorPos(21,7)
  442.  
  443. elseif t1powertick < 10 then
  444. tm1.setCursorPos(22,7)
  445.  
  446. end
  447.  
  448. tm1.write(t1powertick)
  449.  
  450. tm1.setTextColor(colors.white)
  451. tm1.setCursorPos(25,7)
  452. tm1.write(" RF/T")
  453.  
  454. --RPM----
  455. local t1rpm = math.floor(t1.getRotorSpeed())
  456.  
  457. tm1.setTextColor(colors.white)
  458. tm1.setCursorPos(1,9)
  459. tm1.write("RPM:")
  460.  
  461. --color coding
  462. if t1rpm >= 2000 then
  463. tm1.setTextColor(colors.red)
  464.  
  465. elseif (t1rpm < 2000) and (t1rpm >= 1900) then
  466. tm1.setTextColor(colors.orange)
  467.  
  468. elseif (t1rpm < 1900) and (t1rpm > 1825) then
  469. tm1.setTextColor(colors.yellow)
  470.  
  471. elseif (t1rpm <= 1825) and (t1rpm >= 1775) then
  472. tm1.setTextColor(colors.green)
  473.  
  474. elseif (t1rpm < 1775) and (t1rpm > 925) then
  475. tm1.setTextColor(colors.cyan)
  476.  
  477. elseif (t1rpm <= 925) and (t1rpm >= 875) then
  478. tm1.setTextColor(colors.green)
  479.  
  480. elseif (t1rpm < 875) and (t1rpm >= 500) then
  481. tm1.setTextColor(colors.cyan)
  482.  
  483. elseif t1rpm < 500 then
  484. tm1.setTextColor(colors.white)
  485.  
  486. end
  487.  
  488. --adjust cursor
  489. if t1rpm >= 1000 then
  490. tm1.setCursorPos(19,9)
  491.  
  492. elseif (t1rpm < 1000) and (t1rpm >= 100) then
  493. tm1.setCursorPos(20,9)
  494.  
  495. elseif (t1rpm < 100) and (t1rpm >= 10) then
  496. tm1.setCursorPos(21,9)
  497.  
  498. elseif t1rpm < 10 then
  499. tm1.setCursorPos(22,9)
  500.  
  501. end
  502.  
  503. tm1.write(t1rpm)
  504.  
  505. tm1.setTextColor(colors.white)
  506. tm1.setCursorPos(25,9)
  507. tm1.write(" RPM ")
  508.  
  509. --Steam flow----
  510. local t1steam = t1.getFluidFlowRateMax()
  511.  
  512. tm1.setTextColor(colors.white)
  513. tm1.setCursorPos(1,11)
  514. tm1.write("Steam Flow:")
  515.  
  516. --adjust cursor
  517. if t1.getActive() == true then
  518. tm1.setCursorPos(19,11)
  519. tm1.write(t1steam)
  520.  
  521. else
  522. tm1.setCursorPos(22,11)
  523. tm1.write("0.0")
  524.  
  525. end
  526.  
  527. tm1.setTextColor(colors.white)
  528. tm1.setCursorPos(25,11)
  529. tm1.write(" MB/T")
  530.  
  531. --Turbine 2 display----------------------------------------------------
  532. tm2.clear()
  533.  
  534. tm2.setTextColor(colors.white)
  535. tm2.setCursorPos(1,1)
  536. tm2.write("Turbine 2")
  537.  
  538. --status----
  539. tm2.setCursorPos(14,1)
  540. tm2.write("Status:")
  541. tm2.setCursorPos(22,1)
  542.  
  543. if t2.getActive() == true then
  544. tm2.setTextColor(colors.green)
  545. tm2.write("ONLINE")
  546.  
  547. else
  548. tm2.setTextColor(colors.red)
  549. tm2.write("OFFLINE")
  550.  
  551. end
  552.  
  553. --coils----
  554. tm2.setTextColor(colors.white)
  555. tm2.setCursorPos(15,3)
  556. tm2.write("Coils:")
  557. tm2.setCursorPos(22,3)
  558.  
  559. if t2.getInductorEngaged() == true then
  560. tm2.setTextColor(colors.green)
  561. tm2.write("ACTIVE")
  562. else
  563. tm2.setTextColor(colors.red)
  564. tm2.write("INACTIVE")
  565. end
  566.  
  567. --Percent capacitor filled----
  568. local t2per = math.floor((t2.getEnergyStored() / 1000000) * 100)
  569.  
  570. tm2.setTextColor(colors.white)
  571. tm2.setCursorPos(1,5)
  572. tm2.write("Power:")
  573.  
  574. --color coding
  575. if t2per >= 75 then
  576. tm2.setTextColor(colors.green)
  577.  
  578. elseif (t2per < 75) and (t2per >= 50) then
  579. tm2.setTextColor(colors.yellow)
  580.  
  581. elseif (t2per <50) and (t2per >= 25) then
  582. tm2.setTextColor(colors.orange)
  583.  
  584. elseif t2per < 25 then
  585. tm2.setTextColor(colors.red)
  586.  
  587. end
  588.  
  589. --adjust cursor
  590. if t2per >= 100 then
  591. tm2.setCursorPos(20,5)
  592.  
  593. elseif (t2per < 100) and (t2per >= 10) then
  594. tm2.setCursorPos(21,5)
  595.  
  596. elseif t2per < 10 then
  597. tm2.setCursorPos(22,5)
  598.  
  599. end
  600.  
  601. tm2.write(t2per)
  602.  
  603. tm2.setTextColor(colors.white)
  604. tm2.setCursorPos(25,5)
  605. tm2.write(" %")
  606.  
  607. --Power output----
  608. local t2powertick = t2.getEnergyProducedLastTick()
  609.  
  610. tm2.setTextColor(colors.white)
  611. tm2.setCursorPos(1,7)
  612. tm2.write("Rate:")
  613.  
  614. if t2powertick >= 10000 then
  615. tm2.setCursorPos(18,7)
  616.  
  617. elseif (t2powertick < 10000) and (t2powertick >= 1000) then
  618. tm2.setCursorPos(19,7)
  619.  
  620. elseif (t2powertick < 1000) and (t2powertick >= 100) then
  621. tm2.setCursorPos(20,7)
  622.  
  623. elseif (t2powertick < 100) and (t2powertick >= 10) then
  624. tm2.setCursorPos(21,7)
  625.  
  626. elseif t2powertick < 10 then
  627. tm2.setCursorPos(22,7)
  628.  
  629. end
  630.  
  631. tm2.write(t2powertick)
  632.  
  633. tm2.setTextColor(colors.white)
  634. tm2.setCursorPos(25,7)
  635. tm2.write(" RF/T")
  636.  
  637. --RPM----
  638. local t2rpm = math.floor(t2.getRotorSpeed())
  639.  
  640. tm2.setTextColor(colors.white)
  641. tm2.setCursorPos(1,9)
  642. tm2.write("RPM:")
  643.  
  644. --color coding
  645. if t2rpm >= 2000 then
  646. tm2.setTextColor(colors.red)
  647.  
  648. elseif (t2rpm < 2000) and (t2rpm >= 1900) then
  649. tm2.setTextColor(colors.orange)
  650.  
  651. elseif (t2rpm < 1900) and (t2rpm > 1825) then
  652. tm2.setTextColor(colors.yellow)
  653.  
  654. elseif (t2rpm <= 1825) and (t2rpm >= 1775) then
  655. tm2.setTextColor(colors.green)
  656.  
  657. elseif (t2rpm < 1775) and (t2rpm > 925) then
  658. tm2.setTextColor(colors.cyan)
  659.  
  660. elseif (t2rpm <= 925) and (t2rpm >= 875) then
  661. tm2.setTextColor(colors.green)
  662.  
  663. elseif (t2rpm < 875) and (t2rpm >= 500) then
  664. tm2.setTextColor(colors.cyan)
  665.  
  666. elseif t2rpm < 500 then
  667. tm2.setTextColor(colors.white)
  668.  
  669. end
  670.  
  671. --adjust cursor
  672. if t2rpm >= 1000 then
  673. tm2.setCursorPos(19,9)
  674.  
  675. elseif (t2rpm < 1000) and (t2rpm >= 100) then
  676. tm2.setCursorPos(20,9)
  677.  
  678. elseif (t2rpm < 100) and (t2rpm >= 10) then
  679. tm2.setCursorPos(21,9)
  680.  
  681. elseif t2rpm < 10 then
  682. tm2.setCursorPos(22,9)
  683.  
  684. end
  685.  
  686. tm2.write(t2rpm)
  687.  
  688. tm2.setTextColor(colors.white)
  689. tm2.setCursorPos(25,9)
  690. tm2.write(" RPM ")
  691.  
  692. --Steam flow----
  693. local t2steam = t2.getFluidFlowRateMax()
  694.  
  695. tm2.setTextColor(colors.white)
  696. tm2.setCursorPos(1,11)
  697. tm2.write("Steam Flow:")
  698.  
  699. --adjust cursor
  700. if t2.getActive() == true then
  701. tm2.setCursorPos(19,11)
  702. tm2.write(t2steam)
  703.  
  704. else
  705. tm2.setCursorPos(22,11)
  706. tm2.write("0.0")
  707.  
  708. end
  709.  
  710. tm2.setTextColor(colors.white)
  711. tm2.setCursorPos(25,11)
  712. tm2.write(" MB/T")
  713.  
  714.  
  715. --Turbine 3 display----------------------------------------------------
  716. tm3.clear()
  717.  
  718. tm3.setTextColor(colors.white)
  719. tm3.setCursorPos(1,1)
  720. tm3.write("Turbine 3")
  721.  
  722. --status----
  723. tm3.setCursorPos(14,1)
  724. tm3.write("Status:")
  725. tm3.setCursorPos(22,1)
  726.  
  727. if t3.getActive() == true then
  728. tm3.setTextColor(colors.green)
  729. tm3.write("ONLINE")
  730.  
  731. else
  732. tm3.setTextColor(colors.red)
  733. tm3.write("OFFLINE")
  734.  
  735. end
  736.  
  737. --coils----
  738. tm3.setTextColor(colors.white)
  739. tm3.setCursorPos(15,3)
  740. tm3.write("Coils:")
  741. tm3.setCursorPos(22,3)
  742.  
  743. if t3.getInductorEngaged() == true then
  744. tm3.setTextColor(colors.green)
  745. tm3.write("ACTIVE")
  746. else
  747. tm3.setTextColor(colors.red)
  748. tm3.write("INACTIVE")
  749. end
  750.  
  751. --Percent capacitor filled----
  752. local t3per = math.floor((t3.getEnergyStored() / 1000000) * 100)
  753.  
  754. tm3.setTextColor(colors.white)
  755. tm3.setCursorPos(1,5)
  756. tm3.write("Power:")
  757.  
  758. --color coding
  759. if t3per >= 75 then
  760. tm3.setTextColor(colors.green)
  761.  
  762. elseif (t3per < 75) and (t3per >= 50) then
  763. tm3.setTextColor(colors.yellow)
  764.  
  765. elseif (t3per <50) and (t3per >= 25) then
  766. tm3.setTextColor(colors.orange)
  767.  
  768. elseif t3per < 25 then
  769. tm3.setTextColor(colors.red)
  770.  
  771. end
  772.  
  773. --adjust cursor
  774. if t3per >= 100 then
  775. tm3.setCursorPos(20,5)
  776.  
  777. elseif (t3per < 100) and (t3per >= 10) then
  778. tm3.setCursorPos(21,5)
  779.  
  780. elseif t3per < 10 then
  781. tm3.setCursorPos(22,5)
  782.  
  783. end
  784.  
  785. tm3.write(t3per)
  786.  
  787. tm3.setTextColor(colors.white)
  788. tm3.setCursorPos(25,5)
  789. tm3.write(" %")
  790.  
  791. --Power output----
  792. local t3powertick = t3.getEnergyProducedLastTick()
  793.  
  794. tm3.setTextColor(colors.white)
  795. tm3.setCursorPos(1,7)
  796. tm3.write("Rate:")
  797.  
  798. if t3powertick >= 10000 then
  799. tm3.setCursorPos(18,7)
  800.  
  801. elseif (t3powertick < 10000) and (t3powertick >= 1000) then
  802. tm3.setCursorPos(19,7)
  803.  
  804. elseif (t3powertick < 1000) and (t3powertick >= 100) then
  805. tm3.setCursorPos(20,7)
  806.  
  807. elseif (t3powertick < 100) and (t3powertick >= 10) then
  808. tm3.setCursorPos(21,7)
  809.  
  810. elseif t3powertick < 10 then
  811. tm3.setCursorPos(22,7)
  812.  
  813. end
  814.  
  815. tm3.write(t3powertick)
  816.  
  817. tm3.setTextColor(colors.white)
  818. tm3.setCursorPos(25,7)
  819. tm3.write(" RF/T")
  820.  
  821. --RPM----
  822. local t3rpm = math.floor(t3.getRotorSpeed())
  823.  
  824. tm3.setTextColor(colors.white)
  825. tm3.setCursorPos(1,9)
  826. tm3.write("RPM:")
  827.  
  828. --color coding
  829. if t3rpm >= 2000 then
  830. tm3.setTextColor(colors.red)
  831.  
  832. elseif (t3rpm < 2000) and (t3rpm >= 1900) then
  833. tm3.setTextColor(colors.orange)
  834.  
  835. elseif (t3rpm < 1900) and (t3rpm > 1825) then
  836. tm3.setTextColor(colors.yellow)
  837.  
  838. elseif (t3rpm <= 1825) and (t3rpm >= 1775) then
  839. tm3.setTextColor(colors.green)
  840.  
  841. elseif (t3rpm < 1775) and (t3rpm > 925) then
  842. tm3.setTextColor(colors.cyan)
  843.  
  844. elseif (t3rpm <= 925) and (t3rpm >= 875) then
  845. tm3.setTextColor(colors.green)
  846.  
  847. elseif (t3rpm < 875) and (t3rpm >= 500) then
  848. tm3.setTextColor(colors.cyan)
  849.  
  850. elseif t3rpm < 500 then
  851. tm3.setTextColor(colors.white)
  852.  
  853. end
  854.  
  855. --adjust cursor
  856. if t3rpm >= 1000 then
  857. tm3.setCursorPos(19,9)
  858.  
  859. elseif (t3rpm < 1000) and (t3rpm >= 100) then
  860. tm3.setCursorPos(20,9)
  861.  
  862. elseif (t3rpm < 100) and (t3rpm >= 10) then
  863. tm3.setCursorPos(21,9)
  864.  
  865. elseif t3rpm < 10 then
  866. tm3.setCursorPos(22,9)
  867.  
  868. end
  869.  
  870. tm3.write(t3rpm)
  871.  
  872. tm3.setTextColor(colors.white)
  873. tm3.setCursorPos(25,9)
  874. tm3.write(" RPM ")
  875.  
  876. --Steam flow----
  877. local t3steam = t3.getFluidFlowRateMax()
  878.  
  879. tm3.setTextColor(colors.white)
  880. tm3.setCursorPos(1,11)
  881. tm3.write("Steam Flow:")
  882.  
  883. --adjust cursor
  884. if t3.getActive() == true then
  885. tm3.setCursorPos(19,11)
  886. tm3.write(t2steam)
  887.  
  888. else
  889. tm3.setCursorPos(22,11)
  890. tm3.write("0.0")
  891.  
  892. end
  893.  
  894. tm3.setTextColor(colors.white)
  895. tm3.setCursorPos(25,11)
  896. tm3.write(" MB/T")
  897.  
  898.  
  899. --Automatic System Control------------------------------------------------------
  900.  
  901. --Turbine 1 Automatic Controls----
  902. if t1auto == true then
  903.  
  904. --toggle turbine 1
  905. if t1per >= 95 then
  906. t1.setActive(false)
  907.  
  908. elseif t1per <= 0 then
  909. t1.setActive(true)
  910.  
  911. end
  912.  
  913. --toggle coils 1
  914. if t1.getActive() == true then
  915.  
  916. if t1.getRotorSpeed() >= 500 then
  917. t1.setInductorEngaged(true)
  918. else
  919. t1.setInductorEngaged(false)
  920. end
  921.  
  922. else
  923. t1.setInductorEngaged(true)
  924. end
  925.  
  926. else
  927. t1.setActive(false)
  928. end
  929.  
  930. --Turbine 2 Automatic Controls----
  931. if t2auto == true then
  932.  
  933. --toggle turbine 2
  934. if t2per >= 95 then
  935. t2.setActive(false)
  936.  
  937. elseif t2per <= 0 then
  938. t2.setActive(true)
  939.  
  940. end
  941.  
  942. --toggle coils 2
  943. if t2.getActive() == true then
  944.  
  945. if t2.getRotorSpeed() >= 500 then
  946. t2.setInductorEngaged(true)
  947. else
  948. t2.setInductorEngaged(false)
  949. end
  950.  
  951. else
  952. t2.setInductorEngaged(true)
  953. end
  954.  
  955. else
  956. t2.setActive(false)
  957. end
  958.  
  959. --Turbine 3 Automatic Controls----
  960. if t3auto == true then
  961.  
  962. --toggle turbine 3
  963. if t3per >= 95 then
  964. t3.setActive(false)
  965.  
  966. elseif t3per <= 0 then
  967. t3.setActive(true)
  968.  
  969. end
  970.  
  971. --toggle coils 3
  972. if t3.getActive() == true then
  973.  
  974. if t3.getRotorSpeed() >= 500 then
  975. t3.setInductorEngaged(true)
  976. else
  977. t3.setInductorEngaged(false)
  978. end
  979.  
  980. else
  981. t3.setInductorEngaged(true)
  982. end
  983.  
  984. else
  985. t3.setActive(false)
  986. end
  987.  
  988. --Reactor Automatic Controls----
  989. if r1auto == true then
  990.  
  991. --toggle reactor
  992. if (t1.getActive() == false) and (t2.getActive() == false) then
  993. r1.setActive(false)
  994.  
  995. else
  996. r1.setActive(true)
  997. r1.setAllControlRodLevels(100)
  998.  
  999. end
  1000.  
  1001. --rod control
  1002. if temp >= 2000 then
  1003.  
  1004. if rods <= 98 then
  1005. rods = rods + 2
  1006. end
  1007.  
  1008. elseif (temp < 2000) and (temp >= 1500) then
  1009.  
  1010. if rods <= 99 then
  1011. rods = rods + 1
  1012. end
  1013.  
  1014. elseif (temp < 1500) and (temp >= 1000) then
  1015.  
  1016. if rods <= 99 then
  1017. rods = rods + 1
  1018. end
  1019.  
  1020. elseif (temp < 1000) and (temp >= 500) then
  1021. --ideal
  1022.  
  1023. elseif temp < 500 then
  1024.  
  1025. if rods >= 0 then
  1026. rods = rods - 1
  1027. end
  1028.  
  1029. end
  1030.  
  1031. r1.setAllControlRodLevels(rods)
  1032.  
  1033. else
  1034. r1.setAllControlRodLevels(100)
  1035. r1.setActive(false)
  1036.  
  1037. end
  1038.  
  1039. --Button Press--------------------------------------------------------
  1040. os.startTimer(1)
  1041.  
  1042. while true do
  1043. local evt = {os.pullEvent()}
  1044. if evt[1]=="timer" then
  1045. break
  1046. elseif evt[1]=="monitor_touch" then
  1047. local x,y = evt[3],evt[4]
  1048. if evt[2] == "monitor_25" then
  1049.  
  1050. --ON--
  1051. if x>=18 and x<=22 then
  1052. btn(y,"on")
  1053.  
  1054. if y==1 then
  1055. r1.setActive(true)
  1056. r1auto = true
  1057.  
  1058. elseif y==2 then
  1059. t1.setActive(true)
  1060. t1auto = true
  1061.  
  1062. elseif y==3 then
  1063. t2.setActive(true)
  1064. t2auto = true
  1065.  
  1066. elseif y==4 then
  1067. t3.setActive(true)
  1068. t3auto = true
  1069.  
  1070. elseif y==5 then
  1071. redstone.setOutput("top",true)
  1072.  
  1073. end
  1074.  
  1075. --OFF--
  1076. elseif x>25 and x<=30 then
  1077. btn(y,"off")
  1078.  
  1079. if y==1 then
  1080. r1.setActive(false)
  1081. r1auto = false
  1082.  
  1083. elseif y==2 then
  1084. t1.setActive(false)
  1085. t1auto = false
  1086.  
  1087. elseif y==3 then
  1088. t2.setActive(false)
  1089. t2auto = false
  1090.  
  1091. elseif y==4 then
  1092. t3.setActive(false)
  1093. t3auto = false
  1094.  
  1095. elseif y==5 then
  1096. redstone.setOutput("top",false)
  1097.  
  1098. end
  1099. end
  1100. end
  1101. end
  1102. end
  1103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement