SHOW:
|
|
- or go back to the newest paste.
| 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 | if (turbine1.getConnected()) then | |
| 98 | ||
| 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 | return nil | |
| 133 | monitor.setTextColor(colors.red) | |
| 134 | monitor.write('Turbine 1 Disconnected From SYS')
| |
| 135 | end | |
| 136 | ||
| 137 | monitor.setCursorPos(40,6) | |
| 138 | monitor.setTextColor(colors.white) | |
| 139 | if (turbine2.getConnected()) then | |
| 140 | ||
| 141 | monitor.write('Turbine 2 Status')
| |
| 142 | monitor.setCursorPos(40,7) | |
| 143 | if turbine2.getFluidFlowRate()>=1999 then | |
| 144 | monitor.setTextColor(colors.green) | |
| 145 | elseif turbine2.getFluidFlowRate()>=1500 then | |
| 146 | monitor.setTextColor(colors.orange) | |
| 147 | else | |
| 148 | monitor.setTextColor(colors.red) | |
| 149 | end | |
| 150 | monitor.write('Flow Rate: '..turbine2.getFluidFlowRate()..'mb/t')
| |
| 151 | ||
| 152 | monitor.setCursorPos(40,8) | |
| 153 | if turbine2.getRotorSpeed()>=1700 and turbine2.getRotorSpeed()<=1900 then | |
| 154 | monitor.setTextColor(colors.green) | |
| 155 | else | |
| 156 | monitor.setTextColor(colors.red) | |
| 157 | end | |
| 158 | ||
| 159 | monitor.write('Rotor Speed: '..turbine2.getRotorSpeed()..' rpm')
| |
| 160 | ||
| 161 | monitor.setCursorPos(40,9) | |
| 162 | if turbine2.getEnergyProducedLastTick()>= 25000 then | |
| 163 | monitor.setTextColor(colors.green) | |
| 164 | else | |
| 165 | monitor.setTextColor(colors.red) | |
| 166 | end | |
| 167 | monitor.write('Generation: '..turbine2.getEnergyProducedLastTick()..' rf/t')
| |
| 168 | ||
| 169 | else | |
| 170 | monitor.setTextColor(colors.red) | |
| 171 | monitor.write('Turbine 2 Disconnected From SYS')
| |
| 172 | end | |
| 173 | ||
| 174 | monitor.setCursorPos(40,11) | |
| 175 | monitor.setTextColor(colors.white) | |
| 176 | ||
| 177 | if (turbine3.getConnected()) then | |
| 178 | ||
| 179 | monitor.write('Turbine 3 Status')
| |
| 180 | monitor.setCursorPos(40,12) | |
| 181 | if turbine3.getFluidFlowRate()>=1999 then | |
| 182 | monitor.setTextColor(colors.green) | |
| 183 | elseif turbine3.getFluidFlowRate()>=1500 then | |
| 184 | monitor.setTextColor(colors.orange) | |
| 185 | else | |
| 186 | monitor.setTextColor(colors.red) | |
| 187 | end | |
| 188 | monitor.write('Flow Rate: '..turbine3.getFluidFlowRate()..'mb/t')
| |
| 189 | ||
| 190 | monitor.setCursorPos(40,13) | |
| 191 | if turbine3.getRotorSpeed()>=1700 and turbine3.getRotorSpeed()<=1900 then | |
| 192 | monitor.setTextColor(colors.green) | |
| 193 | else | |
| 194 | monitor.setTextColor(colors.red) | |
| 195 | end | |
| 196 | ||
| 197 | monitor.write('Rotor Speed: '..turbine3.getRotorSpeed()..' rpm')
| |
| 198 | ||
| 199 | monitor.setCursorPos(40,14) | |
| 200 | if turbine3.getEnergyProducedLastTick()>= 25000 then | |
| 201 | monitor.setTextColor(colors.green) | |
| 202 | else | |
| 203 | monitor.setTextColor(colors.red) | |
| 204 | end | |
| 205 | monitor.write('Generation: '..turbine3.getEnergyProducedLastTick()..' rf/t')
| |
| 206 | ||
| 207 | else | |
| 208 | monitor.setTextColor(colors.red) | |
| 209 | monitor.write('Turbine 3 Disconnected From SYS')
| |
| 210 | end | |
| 211 | ||
| 212 | monitor.setCursorPos(40,16) | |
| 213 | monitor.setTextColor(colors.white) | |
| 214 | monitor.write('Capacitor Banks:')
| |
| 215 | ||
| 216 | if (turbine1.getConnected()) then | |
| 217 | monitor.setCursorPos(40,17) | |
| 218 | if turbine1.getEnergyStored()>=9900000 then | |
| 219 | monitor.setTextColor(colors.red) | |
| 220 | else | |
| 221 | monitor.setTextColor(colors.green) | |
| 222 | end | |
| 223 | monitor.write('Turbine 1: '..turbine1.getEnergyStored()..' RF')
| |
| 224 | else | |
| 225 | return nil | |
| 226 | end | |
| 227 | ||
| 228 | if (turbine2.getConnected()) then | |
| 229 | monitor.setCursorPos(40,18) | |
| 230 | if turbine2.getEnergyStored()>=9900000 then | |
| 231 | monitor.setTextColor(colors.red) | |
| 232 | else | |
| 233 | monitor.setTextColor(colors.green) | |
| 234 | end | |
| 235 | monitor.write('Turbine 2: '..turbine2.getEnergyStored()..' RF')
| |
| 236 | end | |
| 237 | ||
| 238 | if (turbine3.getConnected()) then | |
| 239 | monitor.setCursorPos(40,19) | |
| 240 | if turbine3.getEnergyStored()>=9900000 then | |
| 241 | monitor.setTextColor(colors.red) | |
| 242 | else | |
| 243 | monitor.setTextColor(colors.green) | |
| 244 | end | |
| 245 | monitor.write('Turbine 3: '..turbine3.getEnergyStored()..' RF')
| |
| 246 | end | |
| 247 | ||
| 248 | ||
| 249 | ||
| 250 | monitor.setCursorPos(1,9) | |
| 251 | monitor.setTextColor(colors.white) | |
| 252 | monitor.write('Control Rod Levels:')
| |
| 253 | monitor.setTextColor(colors.green) | |
| 254 | monitor.setCursorPos(1,10) | |
| 255 | monitor.write('Rods 1-24: '..(100-(reactor.getControlRodLevel(0)))..'%')
| |
| 256 | ||
| 257 | monitor.setCursorPos(20,10) | |
| 258 | monitor.write('Rods 24-48: '..(100-(reactor.getControlRodLevel(1)))..'%')
| |
| 259 | ||
| 260 | monitor.setCursorPos(1,11) | |
| 261 | monitor.write('Rods 72-96: '..(100-(reactor.getControlRodLevel(2)))..'%')
| |
| 262 | ||
| 263 | monitor.setCursorPos(20,11) | |
| 264 | monitor.write('Rods 120-144: '..(100-(reactor.getControlRodLevel(3)))..'%')
| |
| 265 | ||
| 266 | monitor.setCursorPos(1,14) | |
| 267 | monitor.setTextColor(colors.white) | |
| 268 | monitor.write('Reactor Radioactivity')
| |
| 269 | ||
| 270 | monitor.setCursorPos(24,14) | |
| 271 | monitor.write('Fuel Usage')
| |
| 272 | ||
| 273 | monitor.setTextColor(colors.green) | |
| 274 | monitor.setCursorPos(1,15) | |
| 275 | monitor.write(''..reactor.getFuelReactivity()..'%')
| |
| 276 | monitor.setCursorPos(24,15) | |
| 277 | monitor.write(''..reactor.getFuelConsumedLastTick()..' mb/t')
| |
| 278 | ||
| 279 | monitor.setCursorPos(1,16) | |
| 280 | monitor.setTextColor(colors.orange) | |
| 281 | monitor.write('Status:')
| |
| 282 | ||
| 283 | if flashflag==0 then | |
| 284 | flashflag=1 | |
| 285 | if offlineflag==1 then | |
| 286 | monitor.setCursorPos(1,17) | |
| 287 | monitor.setTextColor(colors.lightGray) | |
| 288 | monitor.write('OFFLINE - Manual Override')
| |
| 289 | end | |
| 290 | if emptyflag==1 then | |
| 291 | monitor.setCursorPos(1,17) | |
| 292 | monitor.setTextColor(colors.pink) | |
| 293 | monitor.write('OFFLINE - Fuel Exhausted')
| |
| 294 | end | |
| 295 | if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)>75 then | |
| 296 | monitor.setCursorPos(1,17) | |
| 297 | monitor.setTextColor(colors.yellow) | |
| 298 | monitor.write('ONLINE - Low Power Mode')
| |
| 299 | end | |
| 300 | if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)<=75 then | |
| 301 | monitor.setCursorPos(1,17) | |
| 302 | monitor.setTextColor(colors.orange) | |
| 303 | monitor.write('ONLINE - High Power Mode')
| |
| 304 | end | |
| 305 | else | |
| 306 | flashflag=0 | |
| 307 | end | |
| 308 | ||
| 309 | ||
| 310 | ||
| 311 | ||
| 312 | if reactor.getEnergyProducedLastTick()<=5999 then | |
| 313 | reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyProducedLastTick()/6000))) | |
| 314 | ||
| 315 | elseif reactor.getEnergyProducedLastTick()>=6000 then | |
| 316 | reactor.setAllControlRodLevels(100) | |
| 317 | else | |
| 318 | reactor.setAllControlRodLevels(0) | |
| 319 | end | |
| 320 | ||
| 321 | if (reactor.getFuelAmount()<=100) and offlineflag==0 then | |
| 322 | reactor.setAllControlRodLevels(100) | |
| 323 | reactor.setActive(false) | |
| 324 | emptyflag=1 | |
| 325 | else | |
| 326 | emptyflag=0 | |
| 327 | end | |
| 328 | ||
| 329 | if rs.getInput('bottom')==false and emptyflag==0 then
| |
| 330 | reactor.setActive(true) | |
| 331 | offlineflag=0 | |
| 332 | end | |
| 333 | ||
| 334 | if rs.getInput('bottom')==true and emptyflag==0 then
| |
| 335 | reactor.setActive(false) | |
| 336 | reactor.setAllControlRodLevels(100) | |
| 337 | offlineflag=1 | |
| 338 | end | |
| 339 | sleep(0) | |
| 340 | end |