Advertisement
Mordrack

BigReactor_Turbine

Nov 16th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. optimalFlow = 1750
  2.  
  3. reactor = {}
  4. reactor[0] = peripheral.wrap("BigReactors-Reactor_0")
  5. reactor[1] = peripheral.wrap("BigReactors-Turbine_1")
  6. reactor[2] = peripheral.wrap("BigReactors-Turbine_2")
  7. reactor[3] = peripheral.wrap("BigReactors-Turbine_3")
  8.  
  9. while true do
  10.    
  11.     flowGlobal = 0
  12.    
  13.     for i=1, (#reactor) do
  14.    
  15.         energyPourcent = math.floor(reactor[i].getEnergyStored() / 10000)
  16.         flow = math.floor(optimalFlow * ((100 - energyPourcent)/100))
  17.         flowGlobal = flowGlobal + flow
  18.         reactor[i].setFluidFlowRateMax(flow)
  19.        
  20.         print("Energy Turbine " .. i .. ": " .. energyPourcent)
  21.         print("Flow Turbine " .. i .. ": " .. flow)
  22.     end
  23.    
  24.     flowLast = reactor[0].getEnergyProducedLastTick()
  25.     rodLevel = reactor[0].getControlRodLevel(0)
  26.    
  27.     if flowLast < flowGlobal then
  28.    
  29.         reactor[0].setAllControlRodLevels(rodLevel - 1)
  30.        
  31.     else
  32.        
  33.         reactor[0].setAllControlRodLevels(rodLevel + 1)
  34.        
  35.     end
  36.    
  37.     print("RodLevel: " .. rodLevel)
  38.     print("")
  39.     sleep(1)
  40.    
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement