Vircomore

VircBRTurbine

Aug 9th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.03 KB | None | 0 0
  1. print('ReactorControl Engaged. View Monitor.')
  2.  
  3. emptyflag=0
  4. offlineflag=0
  5. overloadflag=0
  6. flashflag=0
  7.  
  8. reactor=peripheral.wrap('BigReactors-Reactor_4')
  9. turbine1=peripheral.wrap('BigReactors-Turbine_0')
  10. turbine2=peripheral.wrap('BigReactors-Turbine_1')
  11. monitor=peripheral.wrap('front')
  12.  
  13. monitor.setTextScale(1)
  14. monitor.setBackgroundColor(colors.black)
  15.  
  16. while true do
  17.  
  18. monitor.clear()
  19. monitor.setCursorPos(1,1)
  20. monitor.setTextColor(colors.white)
  21. monitor.write('Fuel Level:')
  22. monitor.setCursorPos(1,2)
  23. monitor.setTextColor(colors.yellow)
  24. monitor.write(math.floor(((reactor.getFuelAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Fuel')
  25. monitor.setCursorPos(1,3)
  26. monitor.setTextColor(colors.lightBlue)
  27. monitor.write(math.floor(((reactor.getWasteAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Waste')
  28. monitor.setCursorPos(1,5)
  29. monitor.setTextColor(colors.white)
  30. monitor.write('Control Rod Levels:')
  31. monitor.setTextColor(colors.green)
  32. monitor.setCursorPos(1,6)
  33. monitor.write('Rod 1:  '..(100-(reactor.getControlRodLevel(0)))..'% Depth')
  34. monitor.setCursorPos(1,7)
  35. monitor.write('Rod 2:  '..(100-(reactor.getControlRodLevel(1)))..'% Depth')
  36. monitor.setCursorPos(1,8)
  37. monitor.write('Rod 3:  '..(100-(reactor.getControlRodLevel(2)))..'% Depth')
  38. monitor.setCursorPos(1,9)
  39. monitor.write('Rod 4:  '..(100-(reactor.getControlRodLevel(3)))..'% Depth')
  40. monitor.setCursorPos(1,10)
  41. monitor.write('Rod 5:  '..(100-(reactor.getControlRodLevel(4)))..'% Depth')
  42. monitor.setCursorPos(1,11)
  43. monitor.write('Rod 6:  '..(100-(reactor.getControlRodLevel(5)))..'% Depth')
  44. monitor.setCursorPos(1,13)
  45. monitor.setTextColor(colors.white)
  46. monitor.write('Temperature:')
  47. monitor.setCursorPos(1,14)
  48. monitor.setTextColor(colors.lightGray)
  49. monitor.write('Casing: ')
  50. if reactor.getCasingTemperature()>=650 then
  51.     monitor.setTextColor(colors.purple)
  52.     else if reactor.getCasingTemperature()>=950 then
  53.         monitor.setTextColor(colors.red)
  54.     else
  55.     monitor.setTextColor(colors.green)
  56.     end
  57. end
  58. monitor.write(math.floor(reactor.getCasingTemperature()+0.5)..'C')
  59.  
  60. monitor.setCursorPos(1,15)
  61. monitor.setTextColor(colors.yellow)
  62. monitor.write('Fuel: ')
  63. if reactor.getFuelTemperature()>=650 then
  64.   monitor.setTextColor(colors.purple)
  65.   else if reactor.getFuelTemperature()>=950 then
  66.     monitor.setTextColor(colors.red)
  67.   else
  68.  monitor.setTextColor(colors.green)
  69.   end
  70. end
  71. monitor.write(math.floor(reactor.getFuelTemperature()+0.5)..'C')
  72.  
  73. monitor.setCursorPos(1,17)
  74. monitor.setTextColor(colors.white)
  75. monitor.write('Turbine Status:')
  76. monitor.setCursorPos(1,18)
  77. monitor.setTextColor(colors.blue)
  78. monitor.write('Rotor 1 Speed: ')
  79. if turbine1.getRotorSpeed()>1900 then
  80.   monitor.setTextColor(colors.red)
  81.   else if turbine1.getRotorSpeed()<1700 then
  82.     monitor.setTextColor(colors.gray)
  83.   else
  84.     monitor.setTextColor(colors.green)
  85.   end
  86. end
  87. monitor.write(math.floor(turbine1.getRotorSpeed()))
  88. monitor.write(' RPM')
  89.  
  90.  
  91. monitor.setCursorPos(1,19)
  92. monitor.setTextColor(colors.blue)
  93. monitor.write('Rotor 2 Speed: ')
  94. if turbine2.getRotorSpeed()>1900 then
  95.   monitor.setTextColor(colors.red)
  96.   else if turbine2.getRotorSpeed()<1700 then
  97.     monitor.setTextColor(colors.gray)
  98.   else
  99.     monitor.setTextColor(colors.green)
  100.   end
  101. end
  102. monitor.write(math.floor(turbine2.getRotorSpeed()))
  103. monitor.write(' RPM')
  104.  
  105. monitor.setCursorPos(1,20)
  106. monitor.setTextColor(colors.lime)
  107. monitor.write('Turbine 1 Steam Rate: ')
  108. monitor.setTextColor(colors.lightGray)
  109. monitor.write(turbine1.getFluidFlowRateMax()..' mB/t')
  110. monitor.setCursorPos(1,21)
  111. monitor.setTextColor(colors.lime)
  112. monitor.write('Turbine 2 Steam Rate: ')
  113. monitor.setTextColor(colors.lightGray)
  114. monitor.write(turbine2.getFluidFlowRateMax()..' mB/t')
  115.  
  116. monitor.setCursorPos(1,23)
  117. monitor.setTextColor(colors.white)
  118. monitor.write('Energy Production:')
  119. monitor.setCursorPos(1,24)
  120. monitor.setTextColor(colors.lime)
  121. monitor.write('Reactor: ')
  122. monitor.setTextColor(colors.lightGray)
  123. monitor.write(math.floor(reactor.getEnergyProducedLastTick()+0.5)..' mB/t')
  124. monitor.setCursorPos(1,25)
  125. monitor.setTextColor(colors.cyan)
  126. monitor.write('Turbine 1: ')
  127. monitor.setTextColor(colors.orange)
  128. monitor.write(math.floor(turbine1.getEnergyProducedLastTick()+0.5)..' RF/t')
  129. monitor.setCursorPos(1,26)
  130. monitor.setTextColor(colors.cyan)
  131. monitor.write('Turbine 2: ')
  132. monitor.setTextColor(colors.orange)
  133. monitor.write(math.floor(turbine2.getEnergyProducedLastTick()+0.5)..' RF/t')
  134.  
  135. monitor.setCursorPos(1,28)
  136. monitor.setTextColor(colors.white)
  137. monitor.write('Overall Status:')
  138.  
  139.   if offlineflag==1 then
  140.     monitor.setCursorPos(1,29)
  141.     monitor.clearLine()
  142.     monitor.setTextColor(colors.lightGray)
  143.     monitor.write('Reactor - OFFLINE - Manual Override')
  144.     monitor.setCursorPos(1,30)
  145.     monitor.clearLine()
  146.     monitor.write('Turbine 1 - OFFLINE - Manual Override')
  147.     monitor.setCursorPos(1,31)
  148.     monitor.clearLine()
  149.     monitor.write('Turbine 2 - OFFLINE - Manual Override')
  150.   end
  151.   if emptyflag==1 then
  152.     monitor.setCursorPos(1,29)
  153.     monitor.clearLine()
  154.     monitor.setTextColor(colors.pink)
  155.     monitor.write('Reactor - OFFLINE - Fuel Exhausted')
  156.   end
  157.   if emptyflag==0 and offlineflag==0 then
  158.     monitor.setCursorPos(1,29)
  159.     monitor.clearLine()
  160.     monitor.setTextColor(colors.green)
  161.     monitor.write('Reactor - ONLINE')
  162.   end
  163.   if turbine1.getActive(true) then
  164.     monitor.setCursorPos(1,30)
  165.     monitor.clearLine()
  166.     monitor.setTextColor(colors.green)
  167.     monitor.write('Turbine 1 - ENGAGED')
  168.   end
  169.   if turbine2.getActive(true) then
  170.     monitor.setCursorPos(1,31)
  171.     monitor.clearLine()
  172.     monitor.setTextColor(colors.green)
  173.     monitor.write('Turbine 2 - ENGAGED')
  174.   end
  175.  
  176. if turbine1.getRotorSpeed()<=1750 and offlineflag==0 then
  177.   turbine1.setInductorEngaged(false)
  178.   monitor.setCursorPos(1,32)
  179.   monitor.setTextColor(colors.lightGray)
  180.   monitor.clearLine()
  181.   monitor.write('Inductor Coil 1 - DISENGAGED')
  182. else
  183.   turbine1.setInductorEngaged(true)
  184.   monitor.setCursorPos(1,32)
  185.   monitor.setTextColor(colors.green)
  186.   monitor.clearLine()
  187.   monitor.write('Inductor Coil 1 - ENGAGED')
  188. end
  189.  
  190. if turbine2.getRotorSpeed()<=1750 and offlineflag==0 then
  191.   turbine2.setInductorEngaged(false)
  192.   monitor.setCursorPos(1,33)
  193.   monitor.setTextColor(colors.lightGray)
  194.   monitor.clearLine()
  195.   monitor.write('Inductor Coil 2 - DISENGAGED')
  196. else
  197.   turbine2.setInductorEngaged(true)
  198.   monitor.setCursorPos(1,33)
  199.   monitor.setTextColor(colors.green)
  200.   monitor.clearLine()
  201.   monitor.write('Inductor Coil 2 - ENGAGED')
  202. end
  203.  
  204. if offlineflag==0 and emptyflag==0 and overloadflag==0 then
  205.   if reactor.getFuelTemperature()>=800 then
  206.     reactor.setAllControlRodLevels(90)
  207.   else
  208.     reactor.setAllControlRodLevels(math.floor((reactor.getFuelTemperature()+0.5)/8))
  209.   end
  210. end
  211.  
  212. if offlineflag==0 and emptyflag==0 and overloadflag==0 then
  213.   if turbine1.getRotorSpeed()<1800 and turbine1.getFluidFlowRateMax()<=1760 then
  214.     turbine1.setFluidFlowRateMax(turbine1.getFluidFlowRateMax()+1)
  215.   end
  216.   if turbine2.getRotorSpeed()<1800 and turbine2.getFluidFlowRateMax()<=1760 then
  217.     turbine2.setFluidFlowRateMax(turbine2.getFluidFlowRateMax()+1)
  218.   end
  219.  
  220.   if turbine1.getRotorSpeed()>=1820 and turbine1.getFluidFlowRateMax()>=1740 then
  221.     turbine1.setFluidFlowRateMax(turbine1.getFluidFlowRateMax()-1)
  222.   end
  223.   if turbine2.getRotorSpeed()>=1820 and turbine2.getFluidFlowRateMax()>=1740 then
  224.     turbine2.setFluidFlowRateMax(turbine2.getFluidFlowRateMax()-1)
  225.   end
  226. end
  227.  
  228. if reactor.getFuelAmount()<=100 and offlineflag==0 then
  229.     reactor.setAllControlRodLevels(100)
  230.     reactor.setActive(false)
  231.     turbine1.setActive(false)
  232.     turbine2.setActive(false)
  233.     emptyflag=1
  234. else
  235.     emptyflag=0
  236. end
  237.      
  238. if rs.getInput('bottom')==false and emptyflag==0 then
  239.     reactor.setActive(true)
  240.     turbine1.setActive(true)
  241.     turbine2.setActive(true)
  242.     offlineflag=0
  243. end
  244.  
  245. if rs.getInput('bottom')==true and emptyflag==0 then
  246.     reactor.setActive(false)
  247.     turbine1.setActive(false)
  248.     turbine2.setActive(false)
  249.     reactor.setAllControlRodLevels(100)
  250.     offlineflag=1
  251. end    
  252. sleep(1)
  253. end
Advertisement
Add Comment
Please, Sign In to add comment