Parg60

rotorReactorManagment

Dec 24th, 2020 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. local rotor1 = peripheral.wrap("BigReactors-Turbine_0")
  2. local rotor2 = peripheral.wrap("BigReactors-Turbine_1")
  3. local rotor3 = peripheral.wrap("BigReactors-Turbine_2")
  4. local rotor4 = peripheral.wrap("BigReactors-Turbine_3")
  5.  
  6. local reactor = peripheral.wrap("BigReactors-Reactor_5")
  7.  
  8. rotorActiveCounter = 4
  9.  
  10. function rotorManagment(x)
  11.     if x.getEnergyStored() > 900000 then
  12.         x.setInductorEngaged(false)
  13.  
  14.         if x.getRotorSpeed() < 1700 then
  15.             x.setFluidFlowRateMax(50)
  16.         elseif x.getRotorSpeed() > 1750 then
  17.             x.setFluidFlowRateMax(0)
  18.         end
  19.        
  20.     elseif x.getEnergyStored() < 300000 then
  21.         x.setInductorEngaged(true)
  22.  
  23.         if x.getRotorSpeed() < 1750 then
  24.             x.setFluidFlowRateMax(1400)
  25.         elseif x.getRotorSpeed() > 1825 then
  26.             x.setFluidFlowRateMax(1250)
  27.         end
  28.     end
  29. end
  30.  
  31.  
  32. function reactorManagment(x)
  33.     rotorActiveCounter = 4
  34.     if rotor1.getInductorEngaged() == false then
  35.         rotorActiveCounter = rotorActiveCounter - 1
  36.     end
  37.     if rotor2.getInductorEngaged() == false then
  38.         rotorActiveCounter = rotorActiveCounter - 1
  39.     end
  40.     if rotor3.getInductorEngaged() == false then
  41.         rotorActiveCounter = rotorActiveCounter - 1
  42.     end
  43.     if rotor4.getInductorEngaged() == false then
  44.         rotorActiveCounter = rotorActiveCounter - 1
  45.     end
  46.  
  47.     if rotorActiveCounter == 0 then
  48.         reactor.setAllControlRodLevels(99)
  49.     else
  50.         reactor.setAllControlRodLevels(100 - (rotorActiveCounter * 20))
  51.     end
  52. end
  53.  
  54.  
  55.  
  56. while true do
  57.     rotorManagment(rotor1)
  58.     rotorManagment(rotor2)
  59.     rotorManagment(rotor3)
  60.     rotorManagment(rotor4)
  61.    
  62.     reactorManagment(reactor)
  63.  
  64.     os.sleep(1)
  65. end
Add Comment
Please, Sign In to add comment