Advertisement
alecblaster

BigReactors Computercraft ControlSystem V2

Aug 22nd, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.05 KB | None | 0 0
  1. screen = peripheral.wrap("monitor_20")
  2.  
  3. reactor1 = peripheral.wrap("BigReactors-Reactor_3")
  4. reactor2 = peripheral.wrap("BigReactors-Reactor_4")
  5.  
  6. fuelt1 = 0
  7. fuelt2 = 0
  8.  
  9. while true do
  10.  
  11. Fuel1 = reactor1.getFuelAmount()
  12. Waste1 = reactor1.getWasteAmount()
  13. Max1 = reactor1.getFuelAmountMax()
  14. Rods1 = reactor1.getControlRodLevel(0)
  15. CasingTemp1 = math.floor(reactor1.getCasingTemperature())
  16. FuelTemp1 = math.floor(reactor1.getFuelTemperature())
  17. Battery1 = reactor1.getEnergyStored()
  18. RFT1 = math.floor(reactor1.getEnergyProducedLastTick())
  19.  
  20. Fuelpercent1 = math.floor((Fuel1/Max1)*100)
  21. Wastepercent1 = math.floor((Waste1/Max1)*100)
  22. Batterypercent1 = math.floor((Battery1/10000000)*100)
  23.  
  24.  
  25. Fuel2 = reactor2.getFuelAmount()
  26. Waste2 = reactor2.getWasteAmount()
  27. Max2 = reactor2.getFuelAmountMax()
  28. Rods2 = reactor2.getControlRodLevel(0)
  29. CasingTemp2 = math.floor(reactor2.getCasingTemperature())
  30. FuelTemp2 = math.floor(reactor2.getFuelTemperature())
  31. Battery2 = reactor2.getEnergyStored()
  32. RFT2 = math.floor(reactor2.getEnergyProducedLastTick())
  33.  
  34. Fuelpercent2 = math.floor((Fuel2/Max2)*100)
  35. Wastepercent2 = math.floor((Waste2/Max2)*100)
  36. Batterypercent2 = math.floor((Battery2/10000000))
  37.  
  38. if reactor1.getActive() == true then
  39.     active1 = 1
  40. else
  41.     active1 = 0
  42. end
  43.  
  44. if reactor2.getActive() == true then
  45.     active2 = 1
  46. else
  47.     active2 = 0
  48. end
  49.  
  50.  
  51.  
  52.  
  53.  
  54. screen.setTextScale(2)
  55. screen.setBackgroundColor(32768)
  56. screen.clear()
  57. screen.setBackgroundColor(1)
  58. screen.setTextColor(1)
  59.  
  60. screen.setCursorPos(1,10)
  61. screen.clearLine()
  62. screen.setCursorPos(1,20)
  63. screen.clearLine()
  64.  
  65.  
  66.  
  67.  
  68.  
  69. if active1 == 1 then
  70.  
  71. if Fuelpercent1 > 70 then
  72.     screen.setBackgroundColor(32)
  73. end
  74. if Fuelpercent1 < 71 then
  75.     screen.setBackgroundColor(16)
  76. end
  77. if Fuelpercent1 < 41 then
  78.     screen.setBackgroundColor(2)
  79. end
  80. if Fuelpercent1 < 21 then
  81.     screen.setBackgroundColor(16384)
  82. end
  83.  
  84. screen.setCursorPos(1,1)
  85. screen.clearLine()
  86. screen.setCursorPos(1,2)
  87. screen.clearLine()
  88. screen.setCursorPos(1,3)
  89. screen.clearLine()
  90. screen.setCursorPos(1,4)
  91. screen.clearLine()
  92. screen.setCursorPos(1,5)
  93. screen.clearLine()
  94. screen.setCursorPos(1,6)
  95. screen.clearLine()
  96. screen.setCursorPos(1,7)
  97. screen.clearLine()
  98. screen.setCursorPos(1,8)
  99. screen.clearLine()
  100. screen.setCursorPos(1,9)
  101. screen.clearLine()
  102.  
  103.  
  104. screen.setCursorPos(1,1)
  105. screen.write("________________Reactor 1________________")
  106. screen.setCursorPos(1,3)
  107. screen.write("Fuel:                "..Fuelpercent1.."%")
  108. screen.setCursorPos(1,4)
  109. screen.write("Waste:               "..Wastepercent1.."%")
  110. screen.setCursorPos(1,5)
  111. screen.write("Control Rods:        "..Rods1.."%")
  112. screen.setCursorPos(1,6)
  113. screen.write("Casing Temperature:  "..CasingTemp1.."C")
  114. screen.setCursorPos(1,7)
  115. screen.write("Fuel Temperature:    "..FuelTemp1.."C")
  116. screen.setCursorPos(1,8)
  117. screen.write("Producing:           "..RFT1.." RF/t")
  118. screen.setCursorPos(1,9)
  119. screen.write("Battery:             "..Battery1.." RF / "..Batterypercent1.."%")
  120.  
  121. else
  122.  
  123. screen.setBackgroundColor(32768)
  124. screen.setCursorPos(1,1)
  125. screen.clearLine()
  126. screen.setCursorPos(1,2)
  127. screen.clearLine()
  128. screen.setCursorPos(1,3)
  129. screen.clearLine()
  130. screen.setCursorPos(1,4)
  131. screen.clearLine()
  132. screen.setCursorPos(1,5)
  133. screen.clearLine()
  134. screen.setCursorPos(1,6)
  135. screen.clearLine()
  136. screen.setCursorPos(1,7)
  137. screen.clearLine()
  138. screen.setCursorPos(1,8)
  139. screen.clearLine()
  140. screen.setCursorPos(1,9)
  141. screen.clearLine()
  142. screen.setCursorPos(1,1)
  143. screen.write("________________Reactor 1________________")
  144. screen.setCursorPos(17,4)
  145. screen.setTextColor(16384)
  146. screen.write("Disabled")
  147. screen.setTextColor(1)
  148. end
  149.  
  150.  
  151.  
  152. if active2 == 1 then
  153.  
  154. if Fuelpercent2 > 70 then
  155.     screen.setBackgroundColor(32)
  156. end
  157. if Fuelpercent2 < 71 then
  158.     screen.setBackgroundColor(16)
  159. end
  160. if Fuelpercent2 < 41 then
  161.     screen.setBackgroundColor(2)
  162. end
  163. if Fuelpercent2 < 21 then
  164.     screen.setBackgroundColor(16384)
  165. end
  166.  
  167. screen.setCursorPos(1,11)
  168. screen.clearLine()
  169. screen.setCursorPos(1,12)
  170. screen.clearLine()
  171. screen.setCursorPos(1,13)
  172. screen.clearLine()
  173. screen.setCursorPos(1,14)
  174. screen.clearLine()
  175. screen.setCursorPos(1,15)
  176. screen.clearLine()
  177. screen.setCursorPos(1,16)
  178. screen.clearLine()
  179. screen.setCursorPos(1,17)
  180. screen.clearLine()
  181. screen.setCursorPos(1,18)
  182. screen.clearLine()
  183. screen.setCursorPos(1,19)
  184. screen.clearLine()
  185.  
  186.  
  187. screen.setCursorPos(1,11)
  188. screen.write("________________Reactor 2________________")
  189. screen.setCursorPos(1,13)
  190. screen.write("Fuel:                "..Fuelpercent2.."%")
  191. screen.setCursorPos(1,14)
  192. screen.write("Waste:               "..Wastepercent2.."%")
  193. screen.setCursorPos(1,15)
  194. screen.write("Control Rods:        "..Rods2.."%")
  195. screen.setCursorPos(1,16)
  196. screen.write("Casing Temperature:  "..CasingTemp2.."C")
  197. screen.setCursorPos(1,17)
  198. screen.write("Fuel Temperature:    "..FuelTemp2.."C")
  199. screen.setCursorPos(1,18)
  200. screen.write("Producing:           "..RFT2.." RF/t")
  201. screen.setCursorPos(1,19)
  202. screen.write("Battery:             "..Battery2.." RF / "..Batterypercent2.."%")
  203.  
  204. else
  205.  
  206. screen.setBackgroundColor(32768)
  207. screen.setCursorPos(1,11)
  208. screen.clearLine()
  209. screen.setCursorPos(1,12)
  210. screen.clearLine()
  211. screen.setCursorPos(1,13)
  212. screen.clearLine()
  213. screen.setCursorPos(1,14)
  214. screen.clearLine()
  215. screen.setCursorPos(1,15)
  216. screen.clearLine()
  217. screen.setCursorPos(1,16)
  218. screen.clearLine()
  219. screen.setCursorPos(1,17)
  220. screen.clearLine()
  221. screen.setCursorPos(1,18)
  222. screen.clearLine()
  223. screen.setCursorPos(1,19)
  224. screen.clearLine()
  225. screen.setCursorPos(1,11)
  226. screen.write("________________Reactor 2________________")
  227. screen.setCursorPos(17,14)
  228. screen.setTextColor(16384)
  229. screen.write("Disabled")
  230. screen.setTextColor(1)
  231. end
  232.  
  233.  
  234.  
  235.  
  236.  
  237. if blink == 1 then
  238. blink = 0
  239.  
  240. if Fuelpercent1 == 0 then
  241.     if Fuelpercent2 == 0 then
  242.         outoffuel = 3
  243.     else
  244.         outoffuel = 1
  245.     end
  246. else
  247.     if Fuelpercent2 == 0 then
  248.         outoffuel = 2
  249.     else
  250.         outoffuel = 0
  251.     end
  252. end
  253.  
  254. if active1 == 0 then
  255.     if outoffuel == 3 then
  256.         outoffuel = 2
  257.     end
  258.     if outoffuel == 1 then
  259.         outoffuel = 0
  260.     end
  261. end
  262.  
  263. if active2 == 0 then
  264.     if outoffuel == 3 then
  265.         outoffuel = 1
  266.     end
  267.     if outoffuel == 2 then
  268.         outoffuel = 0
  269.     end
  270. end
  271.  
  272.  
  273. if outoffuel > 0 then
  274.  
  275. screen.setBackgroundColor(1)
  276. screen.setCursorPos(11,7)
  277. screen.write("---------------------")
  278. screen.setCursorPos(11,13)
  279. screen.write("---------------------")
  280.  
  281. screen.setCursorPos(11,8)
  282. screen.write("---------------------")
  283. screen.setCursorPos(11,9)
  284. screen.write("---------------------")
  285. screen.setCursorPos(11,10)
  286. screen.write("---------------------")
  287. screen.setCursorPos(11,11)
  288. screen.write("---------------------")
  289. screen.setCursorPos(11,12)
  290. screen.write("---------------------")
  291.  
  292.  
  293. screen.setCursorPos(17,8)
  294.     screen.setTextColor(16384)
  295.     screen.write("Wanrning")
  296.     screen.setTextColor(32768)
  297.  
  298. if outoffuel == 3 then
  299.     screen.setCursorPos(15,10)
  300.     screen.write("Reactor")
  301.     screen.setCursorPos(23,10)
  302.     screen.write("1&2")
  303.     screen.setCursorPos(26,10)
  304.     screen.write("are")
  305. else
  306.     screen.setCursorPos(16,10)
  307.     screen.write("Reactor")
  308.    
  309.     screen.setCursorPos(24,10)
  310.    
  311.     if outoffuel == 1 then
  312.         screen.write("1")
  313.     else
  314.         screen.write("2")
  315.    
  316.     screen.setCursorPos(26,10)
  317.     screen.write("is")
  318.     end
  319. end
  320.  
  321.    
  322. screen.setCursorPos(16,11)
  323. screen.write("out")
  324. screen.setCursorPos(20,11)
  325. screen.write("of")
  326. screen.setCursorPos(23,11)
  327. screen.write("fuel.")
  328. end
  329.  
  330. else
  331. blink = 1
  332. end
  333.  
  334.  
  335.  
  336. if active1 == 1 then
  337. if (Fuel1 == 70) or (Fuel1 < 70) then
  338. if fuelt1 == 0 then
  339.     if rs.testBundledInput("left",1) then
  340.         rs.setBundledOutput("left",4)
  341.         sleep(0.3)
  342.         rs.setBundledOutput("left",0)
  343.     else
  344.         rs.setBundledOutput("left",2)
  345.         sleep(0.3)
  346.         rs.setBundledOutput("left",0)
  347.     end
  348. else
  349.     fuelt1 = fuelt1 - 1
  350. end
  351. end
  352. end
  353.  
  354.  
  355.  
  356. if active2 == 1 then
  357. if (Fuel2 == 70) or (Fuel2 < 70) then
  358. if fuelt2 == 0 then
  359.     if rs.testBundledInput("left",1) then
  360.         rs.setBundledOutput("left",16)
  361.         sleep(0.3)
  362.         rs.setBundledOutput("left",0)
  363.     else
  364.         rs.setBundledOutput("left",8)
  365.         sleep(0.3)
  366.         rs.setBundledOutput("left",0)
  367.     end
  368. else
  369.     fuelt2 = fuelt2 - 1
  370. end
  371. end
  372. end
  373.  
  374.  
  375.  
  376.  
  377.  
  378. if Batterypercent1 >= 10 then
  379.     reactor1.setAllControlRodLevels(Batterypercent1)
  380. end
  381.  
  382.  
  383. sleep(0)
  384. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement