nate90909

Untitled

Apr 26th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Initialize Variables
  2.  
  3. local reactor
  4. local monitor
  5. local State
  6. local Temp
  7. local Fuel
  8. local Waste
  9. emptyflag=0
  10. offlineflag=0
  11. flashflag=0
  12.  
  13. turbine1 = peripheral.wrap("BigReactors-Turbine_1")
  14. turbine2 = peripheral.wrap("BigReactors-Turbine_2")
  15. turbine3 = peripheral.wrap("BigReactors-Turbine_3")
  16. reactor = peripheral.wrap("back")
  17. monitor = peripheral.wrap("monitor_2")
  18.  
  19. monitor.setTextScale(1)
  20. monitor.setBackgroundColor(colors.black)
  21.  
  22. --Functions
  23.  
  24. function wipeScreen()
  25. term.clear()
  26. term.setCursorPos(1, 1)
  27. end
  28.  
  29. function delayPrint(pause,msg)
  30. print(msg)
  31. sleep(pause)
  32. end
  33.  
  34. --Program
  35.  
  36. wipeScreen()
  37. print("System Control Startup")
  38. sleep(1)
  39. while true do
  40. sleep(1)
  41. reactor.getConnected()
  42.  
  43. monitor.clear()
  44. monitor.setCursorPos(9,1)
  45. monitor.setTextColor(colors.white)
  46. monitor.write('Reactor System Monitor')
  47. monitor.setCursorPos(1,2)
  48. monitor.write('Fuel Level:')
  49. monitor.setCursorPos(1,3)
  50. monitor.setTextColor(colors.yellow)
  51. monitor.write(math.floor((((reactor.getFuelAmount())/(reactor.getFuelAmountMax()))*100)+0.5)..'% Fuel')
  52. monitor.setCursorPos(1,4)
  53. monitor.setTextColor(colors.lightBlue)
  54. monitor.write(math.floor((((reactor.getWasteAmount())/(reactor.getFuelAmountMax()))*100)+0.5)..'% Waste')
  55.  
  56. monitor.setCursorPos(15,2)
  57. monitor.setTextColor(colors.white)
  58. monitor.write('Steam:')
  59. monitor.setCursorPos(13,3)
  60. monitor.setTextColor(colors.green)
  61.  
  62.  
  63. if reactor.getHotFluidAmount()>=30000 and reactor.getHotFluidAmount()<20000 then
  64. monitor.setTextColor(colors.orange)
  65. end
  66.  
  67. if reactor.getHotFluidAmount()>=40000 then
  68. monitor.setTextColor(colors.red)
  69. end
  70.  
  71. monitor.write('Steam Pressure: '..reactor.getHotFluidAmount()..' mb')
  72.  
  73. monitor.setCursorPos(13,3)
  74. monitor.write(' Outlet: '..reactor.getEnergyProducedLastTick()..' mb/t')
  75.  
  76.  
  77. monitor.setCursorPos(1,6)
  78. monitor.setTextColor(colors.white)
  79. monitor.setTextColor(colors.white)
  80. monitor.write('Temperature:')
  81. monitor.setCursorPos(1,7)
  82. if reactor.getFuelTemperature()>=650 then
  83. monitor.setTextColor(colors.purple)
  84. elseif reactor.getFuelTemperature()>=1000 then
  85. monitor.setTextColor(colors.red)
  86. else
  87. monitor.setTextColor(colors.green)
  88. end
  89.  
  90. monitor.write('Fuel: '..reactor.getFuelTemperature()..'C Casing: '..reactor.getCasingTemperature()..'C')
  91.  
  92.  
  93. monitor.setCursorPos(40,1)
  94. monitor.setTextColor(colors.white)
  95. if (turbine1.getConnected()) then
  96.  
  97.  
  98. monitor.write('Turbine 1 Status')
  99. monitor.setCursorPos(40,2)
  100. if turbine1.getFluidFlowRate()>=1999 then
  101. monitor.setTextColor(colors.green)
  102. elseif turbine1.getFluidFlowRate()>=1500 then
  103. monitor.setTextColor(colors.orange)
  104. else
  105. monitor.setTextColor(colors.red)
  106. end
  107.  
  108. monitor.write('Flow Rate: '..turbine1.getFluidFlowRate()..'mb/t')
  109.  
  110. monitor.setCursorPos(40,3)
  111. if turbine1.getRotorSpeed()>=1700 and turbine1.getRotorSpeed()<=1900 then
  112. monitor.setTextColor(colors.green)
  113. else
  114. monitor.setTextColor(colors.red)
  115. end
  116.  
  117.  
  118. monitor.write('Rotor Speed: '..turbine1.getRotorSpeed()..' rpm')
  119.  
  120. monitor.setCursorPos(40,4)
  121. if turbine1.getEnergyProducedLastTick()>= 25000 then
  122. monitor.setTextColor(colors.green)
  123. else
  124. monitor.setTextColor(colors.red)
  125. end
  126.  
  127. monitor.write('Generation: '..turbine1.getEnergyProducedLastTick()..' rf/t')
  128.  
  129. else
  130. monitor.setTextColor(colors.red)
  131. monitor.write('Turbine 1 Disconnected From SYS')
  132. end
  133.  
  134. monitor.setCursorPos(40,6)
  135. monitor.setTextColor(colors.white)
  136. if (turbine2.getConnected()) then
  137.  
  138. monitor.write('Turbine 2 Status')
  139. monitor.setCursorPos(40,7)
  140. if turbine2.getFluidFlowRate()>=1999 then
  141. monitor.setTextColor(colors.green)
  142. elseif turbine2.getFluidFlowRate()>=1500 then
  143. monitor.setTextColor(colors.orange)
  144. else
  145. monitor.setTextColor(colors.red)
  146. end
  147. monitor.write('Flow Rate: '..turbine2.getFluidFlowRate()..'mb/t')
  148.  
  149. monitor.setCursorPos(40,8)
  150. if turbine2.getRotorSpeed()>=1700 and turbine2.getRotorSpeed()<=1900 then
  151. monitor.setTextColor(colors.green)
  152. else
  153. monitor.setTextColor(colors.red)
  154. end
  155.  
  156. monitor.write('Rotor Speed: '..turbine2.getRotorSpeed()..' rpm')
  157.  
  158. monitor.setCursorPos(40,9)
  159. if turbine2.getEnergyProducedLastTick()>= 25000 then
  160. monitor.setTextColor(colors.green)
  161. else
  162. monitor.setTextColor(colors.red)
  163. end
  164. monitor.write('Generation: '..turbine2.getEnergyProducedLastTick()..' rf/t')
  165.  
  166. else
  167. monitor.setTextColor(colors.red)
  168. monitor.write('Turbine 2 Disconnected From SYS')
  169. end
  170.  
  171. monitor.setCursorPos(40,11)
  172. monitor.setTextColor(colors.white)
  173.  
  174. if (turbine3.getConnected()) then
  175.  
  176. monitor.write('Turbine 3 Status')
  177. monitor.setCursorPos(40,12)
  178. if turbine3.getFluidFlowRate()>=1999 then
  179. monitor.setTextColor(colors.green)
  180. elseif turbine3.getFluidFlowRate()>=1500 then
  181. monitor.setTextColor(colors.orange)
  182. else
  183. monitor.setTextColor(colors.red)
  184. end
  185. monitor.write('Flow Rate: '..turbine3.getFluidFlowRate()..'mb/t')
  186.  
  187. monitor.setCursorPos(40,13)
  188. if turbine3.getRotorSpeed()>=1700 and turbine3.getRotorSpeed()<=1900 then
  189. monitor.setTextColor(colors.green)
  190. else
  191. monitor.setTextColor(colors.red)
  192. end
  193.  
  194. monitor.write('Rotor Speed: '..turbine3.getRotorSpeed()..' rpm')
  195.  
  196. monitor.setCursorPos(40,14)
  197. if turbine3.getEnergyProducedLastTick()>= 25000 then
  198. monitor.setTextColor(colors.green)
  199. else
  200. monitor.setTextColor(colors.red)
  201. end
  202. monitor.write('Generation: '..turbine3.getEnergyProducedLastTick()..' rf/t')
  203.  
  204. else
  205. monitor.setTextColor(colors.red)
  206. monitor.write('Turbine 3 Disconnected From SYS')
  207. end
  208.  
  209. monitor.setCursorPos(40,16)
  210. monitor.setTextColor(colors.white)
  211. monitor.write('Capacitor Banks:')
  212.  
  213. if (turbine1.getConnected()) then
  214. monitor.setCursorPos(40,17)
  215. if turbine1.getEnergyStored()>=9900000 then
  216. monitor.setTextColor(colors.red)
  217. else
  218. monitor.setTextColor(colors.green)
  219. end
  220. monitor.write('Turbine 1: '..turbine1.getEnergyStored()..' RF')
  221. end
  222.  
  223. if (turbine2.getConnected()) then
  224. monitor.setCursorPos(40,18)
  225. if turbine2.getEnergyStored()>=9900000 then
  226. monitor.setTextColor(colors.red)
  227. else
  228. monitor.setTextColor(colors.green)
  229. end
  230. monitor.write('Turbine 2: '..turbine2.getEnergyStored()..' RF')
  231. end
  232.  
  233. if (turbine3.getConnected()) then
  234. monitor.setCursorPos(40,19)
  235. if turbine3.getEnergyStored()>=9900000 then
  236. monitor.setTextColor(colors.red)
  237. else
  238. monitor.setTextColor(colors.green)
  239. end
  240. monitor.write('Turbine 3: '..turbine3.getEnergyStored()..' RF')
  241. end
  242.  
  243.  
  244.  
  245. monitor.setCursorPos(1,9)
  246. monitor.setTextColor(colors.white)
  247. monitor.write('Control Rod Levels:')
  248. monitor.setTextColor(colors.green)
  249. monitor.setCursorPos(1,10)
  250. monitor.write('Rods 1-24: '..(100-(reactor.getControlRodLevel(0)))..'%')
  251.  
  252. monitor.setCursorPos(20,10)
  253. monitor.write('Rods 24-48: '..(100-(reactor.getControlRodLevel(1)))..'%')
  254.  
  255. monitor.setCursorPos(1,11)
  256. monitor.write('Rods 72-96: '..(100-(reactor.getControlRodLevel(2)))..'%')
  257.  
  258. monitor.setCursorPos(20,11)
  259. monitor.write('Rods 120-144: '..(100-(reactor.getControlRodLevel(3)))..'%')
  260.  
  261. monitor.setCursorPos(1,14)
  262. monitor.setTextColor(colors.white)
  263. monitor.write('Reactor Radioactivity')
  264.  
  265. monitor.setCursorPos(24,14)
  266. monitor.write('Fuel Usage')
  267.  
  268. monitor.setTextColor(colors.green)
  269. monitor.setCursorPos(1,15)
  270. monitor.write(''..reactor.getFuelReactivity()..'%')
  271. monitor.setCursorPos(24,15)
  272. monitor.write(''..reactor.getFuelConsumedLastTick()..' mb/t')
  273.  
  274. monitor.setCursorPos(1,16)
  275. monitor.setTextColor(colors.orange)
  276. monitor.write('Status:')
  277.  
  278. if flashflag==0 then
  279. flashflag=1
  280. if offlineflag==1 then
  281. monitor.setCursorPos(1,17)
  282. monitor.setTextColor(colors.lightGray)
  283. monitor.write('OFFLINE - Manual Override')
  284. end
  285. if emptyflag==1 then
  286. monitor.setCursorPos(1,17)
  287. monitor.setTextColor(colors.pink)
  288. monitor.write('OFFLINE - Fuel Exhausted')
  289. end
  290. if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)>75 then
  291. monitor.setCursorPos(1,17)
  292. monitor.setTextColor(colors.yellow)
  293. monitor.write('ONLINE - Low Power Mode')
  294. end
  295. if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)<=75 then
  296. monitor.setCursorPos(1,17)
  297. monitor.setTextColor(colors.orange)
  298. monitor.write('ONLINE - High Power Mode')
  299. end
  300. else
  301. flashflag=0
  302. end
  303.  
  304.  
  305.  
  306.  
  307. if reactor.getEnergyProducedLastTick()<=5999 then
  308. reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyProducedLastTick()/6000)))
  309.  
  310. elseif reactor.getEnergyProducedLastTick()>=6000 then
  311. reactor.setAllControlRodLevels(100)
  312. else
  313. reactor.setAllControlRodLevels(0)
  314. end
  315.  
  316. if (reactor.getFuelAmount()<=100) and offlineflag==0 then
  317. reactor.setAllControlRodLevels(100)
  318. reactor.setActive(false)
  319. emptyflag=1
  320. else
  321. emptyflag=0
  322. end
  323.  
  324. if rs.getInput('bottom')==false and emptyflag==0 then
  325. reactor.setActive(true)
  326. offlineflag=0
  327. end
  328.  
  329. if rs.getInput('bottom')==true and emptyflag==0 then
  330. reactor.setActive(false)
  331. reactor.setAllControlRodLevels(100)
  332. offlineflag=1
  333. end
  334. sleep(0)
  335. end
Advertisement
Add Comment
Please, Sign In to add comment