nate90909

Untitled

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