Advertisement
Kohjen

ReactorSteamVariaent

Jan 12th, 2021 (edited)
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.88 KB | None | 0 0
  1. --[[
  2. Reactor Steam variant V1
  3.  
  4. differs from regular recator by tracking the steam and water levels and removing the energy buffer marker, as that is no longer needed
  5. colours:
  6. 8192 = green
  7. 16384 = red
  8. 32768 = black
  9. 16 = yellow
  10.  
  11. pastebin get rxqvHs3z startup
  12. --]]
  13.  
  14. reactor = peripheral.wrap("right")
  15. monitor = peripheral.wrap("left")
  16. MAXWIDTH = 29
  17. MAXHIGHT = 26
  18. GRAPHMAX = 20 -- Max for the left side graphs, giving space for controll rod graph
  19. FUELMAX = reactor.getFuelAmountMax()
  20. WATERMAX = reactor.getCoolantAmountMax()
  21. STEAMMAX = reactor.getHotFluidAmountMax()
  22. HEATMAX = 2000
  23. monitor.setBackgroundColour(32768)
  24. monitor.clear()
  25. monitor.setCursorBlink(false)
  26. while(reactor.getActive)
  27. do
  28.  
  29.  
  30. fuel = reactor.getFuelAmount()
  31. reactorEnergy = reactor.getEnergyStored()
  32. controlRodLevel = reactor.getControlRodLevel(1)
  33. water = reactor.getCoolantAmount()
  34. steam = reactor.getHotFluidAmount()
  35. heat = reactor.getFuelTemperature()
  36.  
  37.  
  38. --Level marker for reactor fuel Level
  39. monitor.setBackgroundColour(32768)
  40. monitor.setTextColor(1)
  41. monitor.setCursorPos(1,1)
  42. monitor.write("Fuel Level:")
  43. monitor.setCursorPos(1,2)
  44. monitor.write("--------------------")
  45.  
  46. -- i reprecents the hight and pos of the graph while j is the width of the graph
  47. for i=3,5,1
  48. do
  49. for j = 1, GRAPHMAX, 1
  50. do
  51. monitor.setCursorPos(j,i)
  52. if(0<j and j<=5)
  53.  
  54. then
  55. monitor.setBackgroundColour(16384)
  56. if( ((fuel/FUELMAX)*20) >= j )
  57. then
  58. monitor.setTextColor(1)
  59. else
  60. monitor.setTextColor(16384)
  61. end
  62. monitor.write("|")
  63. elseif(5<j and j<=10)
  64. then
  65. monitor.setBackgroundColour(2)
  66. if( ((fuel/FUELMAX)*20) >= j )
  67. then
  68. monitor.setTextColor(1)
  69. else
  70. monitor.setTextColor(2)
  71. end
  72. monitor.write("|")
  73. elseif(10<j)
  74. then
  75. monitor.setBackgroundColour(8192)
  76. if( ((fuel/FUELMAX)*20) >= j )
  77. then
  78. monitor.setTextColor(1)
  79. else
  80. monitor.setTextColor(8192)
  81.  
  82. end
  83. monitor.write("|")
  84. end
  85.  
  86. end
  87. end
  88.  
  89. --Water Level marker
  90. monitor.setBackgroundColour(32768)
  91. monitor.setTextColor(1)
  92. monitor.setCursorPos(1,6)
  93. monitor.write("Water Level:")
  94. monitor.setCursorPos(1,7)
  95. monitor.write("--------------------")
  96.  
  97. -- i reprecents the hight and pos of the graph while j is the width of the graph
  98.  
  99. for i=8,10,1
  100. do
  101. for j = 1, GRAPHMAX, 1
  102. do
  103. monitor.setCursorPos(j,i)
  104. if(0<j and j<=5)
  105.  
  106. then
  107. monitor.setBackgroundColour(16384)
  108. if( ((water/WATERMAX)*20) >= j )
  109. then
  110. monitor.setTextColor(1)
  111. else
  112. monitor.setTextColor(16384)
  113. end
  114. monitor.write("|")
  115. elseif(5<j and j<=10)
  116. then
  117. monitor.setBackgroundColour(2)
  118. if( ((water/WATERMAX)*20) >= j )
  119. then
  120. monitor.setTextColor(1)
  121. else
  122. monitor.setTextColor(2)
  123. end
  124. monitor.write("|")
  125. elseif(10<j)
  126. then
  127. monitor.setBackgroundColour(8192)
  128. if( ((water/WATERMAX)*20) >= j )
  129. then
  130. monitor.setTextColor(1)
  131. else
  132. monitor.setTextColor(8192)
  133.  
  134. end
  135. monitor.write("|")
  136. end
  137.  
  138. end
  139. end
  140.  
  141.  
  142.  
  143. --Heat Level
  144. monitor.setBackgroundColour(32768)
  145. monitor.setTextColor(1)
  146. monitor.setCursorPos(1,11)
  147. monitor.write("Heat Level:")
  148. monitor.setCursorPos(1,12)
  149. monitor.write("--------------------")
  150.  
  151. -- i reprecents the hight and pos of the graph while j is the width of the graph
  152. for i=13,15,1
  153. do
  154. for j = 1, GRAPHMAX, 1
  155. do
  156. monitor.setCursorPos(j,i)
  157. if(0<j and j<=10)
  158. then
  159. monitor.setBackgroundColour(8192)
  160. if( ((heat/HEATMAX)*20) >= j )
  161. then
  162. monitor.setTextColor(1)
  163. else
  164. monitor.setTextColor(8192)
  165. end
  166. monitor.write("|")
  167. elseif(10<j and j<=15)
  168. then
  169. monitor.setBackgroundColour(2)
  170. if( ((heat/HEATMAX)*20) >= j )
  171. then
  172. monitor.setTextColor(1)
  173. else
  174. monitor.setTextColor(2)
  175. end
  176. monitor.write("|")
  177. elseif(15<j)
  178. then
  179. monitor.setBackgroundColour(16384)
  180. if( ((heat/HEATMAX)*20) >= j )
  181. then
  182. monitor.setTextColor(1)
  183. else
  184. monitor.setTextColor(16384)
  185. end
  186. monitor.write("|")
  187. end
  188.  
  189. end
  190. end
  191.  
  192.  
  193.  
  194.  
  195.  
  196. --steam level
  197.  
  198. monitor.setTextColor(1)
  199. monitor.setBackgroundColour(32768)
  200. monitor.setCursorPos(1,16)
  201. monitor.write("Power Per Tick:")
  202. monitor.setCursorPos(1,17)
  203. monitor.write("--------------------")
  204.  
  205. -- i reprecents the hight and pos of the graph while j is the width of the graph
  206.  
  207. for i=18,20,1
  208. do
  209. for j = 1, GRAPHMAX, 1
  210. do
  211.  
  212. monitor.setCursorPos(j,i)
  213. if(0<j and j<=10)
  214. then
  215. monitor.setBackgroundColour(8192)
  216. if( ((steam/STEAMMAX)*20) >= j )
  217. then
  218. monitor.setTextColor(1)
  219. else
  220. monitor.setTextColor(8192)
  221. end
  222. monitor.write("|")
  223. elseif(10<j and j<=15)
  224. then
  225. monitor.setBackgroundColour(2)
  226. if( ((steam/STEAMMAX)*20) >= j )
  227. then
  228. monitor.setTextColor(1)
  229. else
  230. monitor.setTextColor(2)
  231. end
  232. monitor.write("|")
  233. elseif(15<j)
  234. then
  235. monitor.setBackgroundColour(16384)
  236. if( ((steam/STEAMMAX)*20) >= j )
  237. then
  238. monitor.setTextColor(1)
  239. else
  240. monitor.setTextColor(16384)
  241. end
  242. monitor.write("|")
  243. end
  244.  
  245. end
  246. end
  247.  
  248.  
  249. --Control rod Level
  250. monitor.setBackgroundColour(32768)
  251. monitor.setTextColor(1)
  252. monitor.setCursorPos(21,2)
  253. monitor.write(" Control")
  254. monitor.setCursorPos(21,3)
  255. monitor.write(" Rod:")
  256. monitor.setCursorPos(21,4)
  257. monitor.write(" ")
  258. monitor.write(math.floor((controlRodLevel/100) *100))
  259. monitor.write("%")
  260. monitor.setCursorPos(21,5)
  261. monitor.write("---------")
  262.  
  263.  
  264. for i=21, 29 ,1
  265. do
  266. for j = 6, MAXHIGHT, 1
  267. do
  268. monitor.setCursorPos(i,j)
  269.  
  270. if( (((controlRodLevel/100) * 20) + 6) >= j and 22<i and i<28)
  271. then
  272. monitor.setTextColor(32768)
  273. else
  274. monitor.setTextColor(16)
  275. end
  276. monitor.setBackgroundColour(16)
  277.  
  278. monitor.write("|")
  279.  
  280. end
  281. end
  282.  
  283. --Control rod adjustment
  284. inverseSteamLvl = math.floor((steam/STEAMMAX) * 100)
  285. reactor.setAllControlRodLevels(inverseSteamLvl)
  286.  
  287.  
  288. sleep(.01)
  289.  
  290. --End WhileLoop
  291. end
  292.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement