Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReactorCount = 0
- local Reactor = {}
- local TurbineCount = 0
- local Turbine = {}
- local Capacitor = {}
- local CapConnections = 0
- local Computers = {}
- local CompCount = 0
- local Started = false
- local Status = "normal"
- local on = on
- --Debug--
- Debug = true
- --Enderio Capacitor Bank Calculations--
- CapCount = 1154
- CapBasic = 1000000
- CapStandard = 5000000
- CapVibrant = 25000000
- CapType = (CapBasic)
- TotalCapacity = (CapCount) * (CapType)
- --Enderio Capacitor Bank Fill Levels--
- EmptyLevel = (TotalCapacity * 0.01)
- LowLevel = (TotalCapacity * 0.15)
- MedLevel = (TotalCapacity * 0.35)
- HighLevel = (TotalCapacity * 0.65)
- FullLevel = (TotalCapacity * 0.95)
- --Program Functions--
- --Debug--
- function debugPeripherals()
- shell.run("clear")
- print("Debug On")
- print("----------")
- print(" ")
- print("Reactors Connected: ", ReactorCount)
- print("Reactor Connected: ", Reactor[1].getConnected())
- print("Turbines Connected: ", TurbineCount)
- print("Turbine 1 Connected: ", Turbine[1].getConnected())
- print("Turbine 2 Connected: ", Turbine[2].getConnected())
- print("Cap. Banks Connected: ", CapConnections)
- print("Capacitor Count: ", CapCount)
- print("Capacitor Type: ", CapType)
- print("Total Capacity: ", TotalCapacity)
- print("Computers Connected: ", CompCount)
- print(" ")
- print("Press any key to Continue.")
- wait = read()
- shell.run("clear")
- print("Debug On")
- print("----------")
- print()
- print("Empty Level: ", EmptyLevel)
- print("Low Level: ", LowLevel)
- print("Medium Level: ", MedLevel)
- print("High Level: ", HighLevel)
- print("Full Level: ", FullLevel)
- print()
- print("Press any key to Continue")
- wait = read()
- end
- --Peripheral Search--
- function peripheralSearch()
- print("Initializing Connections...")
- sleep(.2)
- for a,b in pairs(peripheral.getNames()) do
- if peripheral.getType(b) == "BigReactors-Turbine" then
- print("Turbine Synced.")
- Turbine[#Turbine+1] = peripheral.wrap(b)
- TurbineCount = TurbineCount + 1
- sleep(.15)
- elseif peripheral.getType(b) == "tile_blockcapacitorbank_name" then
- print("Capacitor Bank Synced.")
- Capacitor[#Capacitor+1] = peripheral.wrap(b)
- CapConnections = CapConnections + 1
- sleep(.15)
- elseif peripheral.getType(b) == "BigReactors-Reactor" then
- print("Reactor Synced.")
- Reactor[#Reactor+1] = peripheral.wrap(b)
- ReactorCount = ReactorCount + 1
- sleep(.15)
- elseif peripheral.getType(b) == "computer" then
- print("Computer Synced.")
- Computers[#Computers+1] = peripheral.wrap(b)
- CompCount = CompCount + 1
- sleep(.15)
- elseif peripheral.getType(b) == "drive" then
- TestDrive = peripheral.wrap(b)
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v) =='drive' then
- LocalDrive = peripheral.wrap(v)
- end
- end
- if TestDrive == LocalDrive then
- print("Command Drive Initialized")
- sleep(.15)
- else
- print("Incompatible Drive.")
- wait = read()
- end
- else
- print("Incompatible Device.")
- sleep(.15)
- end
- end
- sleep(5)
- print()
- print()
- print()
- end
- --System Start--
- function systemStart(Boot)
- if Boot == false then
- print("Starting Computers.")
- sleep(.15)
- print("Please Wait..")
- for a,b in pairs(Computers) do
- b.turnOn()
- sleep(.25)
- end
- Started = true
- print("All Computers Started")
- sleep(.2)
- else
- for a,b in pairs(Computers) do
- if b.isOn() == false then
- b.turnOn()
- if Debug == true then
- print("Connection Reestablished")
- end
- end
- end
- end
- end
- --System ShutDown--
- --Yellow Alert--
- --Red Alert--
- --Defense Systems--
- --Offensive Systems--
- --WarpCore Operations--
- --Stargate Command--
- --Self Destruct Sequence--
- --Full Power Operation--
- --Overdrive Operation--
- --Economy Operation--
- function economy()
- CapEnergyStored = Capacitor[1].getEnergyStored()
- EnergyStored = (CapEnergyStored) * (CapCount)
- if Debug == true then
- print(EnergyStored)
- end
- if EnergyStored <= EmptyLevel or EnergyStored == 0 then
- Reactor[1].setAllControlRodLevels(11)
- Turbine[1].setFluidFlowRateMax(1270)
- Turbine[2].setFluidFlowRateMax(1270)
- elseif EnergyStored >= EmptyLevel and EnergyStored <= LowLevel then
- Reactor[1].setAllControlRodLevels(11)
- Turbine[1].setFluidFlowRateMax(1260)
- Turbine[2].setFluidFlowRateMax(1260)
- elseif EnergyStored >= LowLevel and EnergyStored <= MedLevel then
- Reactor[1].setAllControlRodLevels(37)
- Turbine[1].setFluidFlowRateMax(1260)
- Turbine[2].setFluidFlowRateMax(550)
- elseif EnergyStored >= MedLevel and EnergyStored < HighLevel then
- Reactor[1].setAllControlRodLevels(61)
- Turbine[1].setFluidFlowRateMax(1260)
- Turbine[2].setFluidFlowRateMax(0)
- elseif EnergyStored >= HighLevel and EnergyStored <= FullLevel then
- Reactor[1].setAllControlRodLevels(82)
- Turbine[1].setFluidFlowRateMax(550)
- Turbine[2].setFluidFlowRateMax(0)
- elseif EnergyStored >= FullLevel then
- Reactor[1].setAllControlRodLevels(100)
- end
- print("Running Economy Operation")
- end
- --Normal Running Operations--
- function normalOperation()
- CapEnergyStored = Capacitor[1].getEnergyStored()
- EnergyStored = (CapEnergyStored) * (CapCount)
- if Debug == true then
- print(EnergyStored)
- end
- if EnergyStored <= EmptyLevel or EnergyStored == 0 then
- Reactor[1].setAllControlRodLevels(11)
- Turbine[1].setFluidFlowRateMax(1270)
- Turbine[2].setFluidFlowRateMax(1270)
- elseif EnergyStored >= EmptyLevel and EnergyStored <= LowLevel then
- Reactor[1].setAllControlRodLevels(11)
- Turbine[1].setFluidFlowRateMax(1260)
- Turbine[2].setFluidFlowRateMax(1260)
- elseif EnergyStored >= LowLevel and EnergyStored <= MedLevel then
- Reactor[1].setAllControlRodLevels(37)
- Turbine[1].setFluidFlowRateMax(1260)
- Turbine[2].setFluidFlowRateMax(550)
- elseif EnergyStored >= MedLevel and EnergyStored < HighLevel then
- Reactor[1].setAllControlRodLevels(61)
- Turbine[1].setFluidFlowRateMax(1260)
- Turbine[2].setFluidFlowRateMax(0)
- elseif EnergyStored >= HighLevel and EnergyStored <= FullLevel then
- Reactor[1].setAllControlRodLevels(82)
- Turbine[1].setFluidFlowRateMax(550)
- Turbine[2].setFluidFlowRateMax(0)
- elseif EnergyStored >= FullLevel then
- Reactor[1].setAllControlRodLevels(100)
- end
- print("Running Normal Operation")
- end
- --Run Routine--
- peripheralSearch()
- if Debug == true then
- debugPeripherals()
- end
- systemStart(Started)
- while true do
- local myTimer = os.startTimer(5)
- local evt = {os.pullEvent()}
- if evt[1] == "timer" and evt[2] == myTimer and on then
- if Status == "normal" then
- normalOperation()
- systemStart(Started)
- elseif Status == "economy" then
- economy()
- systemStart(Started)
- end
- elseif evt[1] == "disk" then
- for a,b in pairs(Computers) do
- b.turnOn()
- end
- on = true
- elseif evt[1] == "disk_eject" then
- for a,b in pairs(Computers) do
- b.shutdown()
- end
- on = false
- end
- os.cancelTimer(myTimer)
- end
Advertisement
Add Comment
Please, Sign In to add comment