Guest User

battest

a guest
Sep 26th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.63 KB | None | 0 0
  1. local ReactorCount = 0
  2. local Reactor = {}
  3. local TurbineCount = 0
  4. local Turbine = {}
  5. local Capacitor = {}
  6. local CapConnections = 0
  7.  
  8. function peripheralSearch()
  9.  
  10.   print("Initializing Connections...")
  11.   sleep(.2)
  12.    
  13.   for a,b in pairs(peripheral.getNames()) do
  14.  
  15.     if peripheral.getType(b) == "BigReactors-Turbine" then
  16.       print("Turbine Synced.")
  17.       Turbine[#Turbine+1] = peripheral.wrap(b)
  18.       TurbineCount = TurbineCount + 1
  19.       sleep(.15)
  20.      
  21.     elseif peripheral.getType(b) == "tile_blockcapacitorbank_name" then
  22.       print("Capacitor Bank Synced")
  23.       Capacitor[#Capacitor+1] = peripheral.wrap(b)
  24.       CapConnections = CapConnections + 1
  25.       sleep(.15)
  26.      
  27.     elseif peripheral.getType(b) == "BigReactors-Reactor" then
  28.       print("Reactor Synced.")
  29.       Reactor[#Reactor+1] = peripheral.wrap(b)
  30.       ReactorCount = ReactorCount + 1
  31.       sleep(.15)      
  32.     else    
  33.       print("Incompatible Device.")
  34.       sleep(.15)
  35.     end
  36.    end  
  37. sleep(.5)
  38. print()
  39. print()
  40. print()
  41. end
  42.  
  43.  
  44. --Capacitor Bank Calculations--
  45. CapCount = 1154
  46. CapBasic = 1000000
  47. CapStandard = 5000000
  48. CapVibrant = 25000000
  49. CapType = (CapBasic)
  50. TotalCapacity = (CapCount) * (CapType)
  51.  
  52. --Start-up Peripheral Detection--
  53. peripheralSearch()
  54.  
  55. --Debug--
  56. Debug = true
  57.  
  58. if Debug == true then
  59.   shell.run("clear")
  60.   print("Debug On")
  61.   print("----------")
  62.   print(" ")
  63.   print("Reactors Connected:   ", ReactorCount)
  64.   print("Reactor Connected:    ", Reactor[1].getConnected())
  65.   print("Turbines Connected:   ", TurbineCount)
  66.   print("Turbine 1 Connected:  ", Turbine[1].getConnected())
  67.   print("Turbine 2 Connected:  ", Turbine[2].getConnected())
  68.   print("Cap. Banks Connected: ", CapConnections)
  69.   print("Capacitor Count:    ", CapCount)
  70.   print("Capacitor Type:     ", CapType)
  71.   print("Total Capacity:  ", TotalCapacity)
  72.   print(" ")
  73.   print("Press any key to Continue.")
  74.   wait = read()
  75. end    
  76.  
  77. --Capacitor Bank Fill Levels--
  78. EmptyLevel = (TotalCapacity * 0.01)
  79. LowLevel = (TotalCapacity * 0.15)
  80. MedLevel = (TotalCapacity * 0.35)
  81. HighLevel = (TotalCapacity * 0.65)
  82. FullLevel = (TotalCapacity * 0.95)
  83.  
  84. if Debug == true then
  85.   print("Empty Level:  ", EmptyLevel)
  86.   print("Low Level:    ", LowLevel)
  87.   print("Medium Level: ", MedLevel)
  88.   print("High Level:   ", HighLevel)
  89.   print("Full Level:   ", FullLevel)
  90.   sleep(5)
  91.   print("Actual Level: ")
  92. end
  93.  
  94. while true do
  95.   CapEnergyStored = Capacitor[1].getEnergyStored()
  96.   EnergyStored = (CapEnergyStored) * (CapCount)
  97.  
  98.   if Debug == true then
  99.     print(EnergyStored)
  100.   end
  101.    
  102.   if EnergyStored <= EmptyLevel or EnergyStored == 0 then
  103.     Reactor[1].setAllControlRodLevels(11)
  104.     Turbine[1].setFluidFlowRateMax(1270)
  105.     Turbine[2].setFluidFlowRateMax(1270)
  106.  
  107.   elseif EnergyStored >= EmptyLevel and EnergyStored <= LowLevel then
  108.     Reactor[1].setAllControlRodLevels(11)
  109.     Turbine[1].setFluidFlowRateMax(1260)
  110.     Turbine[2].setFluidFlowRateMax(1260)
  111.  
  112.   elseif EnergyStored >= LowLevel and EnergyStored <= MedLevel then
  113.     Reactor[1].setAllControlRodLevels(37)
  114.     Turbine[1].setFluidFlowRateMax(1260)
  115.     Turbine[2].setFluidFlowRateMax(550)
  116.  
  117.   elseif EnergyStored >= MedLevel and EnergyStored < HighLevel then
  118.     Reactor[1].setAllControlRodLevels(61)
  119.     Turbine[1].setFluidFlowRateMax(1260)
  120.     Turbine[2].setFluidFlowRateMax(0)
  121.  
  122.   elseif EnergyStored >= HighLevel and EnergyStored <= FullLevel then
  123.     Reactor[1].setAllControlRodLevels(82)
  124.     Turbine[1].setFluidFlowRateMax(550)
  125.     Turbine[2].setFluidFlowRateMax(0)
  126.  
  127.   elseif EnergyStored >= FullLevel then
  128.     Reactor[1].setAllControlRodLevels(100)
  129.   end
  130. sleep(5)    
  131. end
Advertisement
Add Comment
Please, Sign In to add comment