Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Stargate
- local ReactorCount = 0
- local ReactorPassiveCount = 0
- local ReactorActiveCount = 0
- local ReactorPassive = {}
- local ReactorActive = {}
- local TurbineCount = 0
- local Turbine = {}
- local Capacitor = {}
- local CapConnections = 0
- local Computers = {}
- local CompCount = 0
- local Started = false
- local Status = "normal"
- local on = false
- local hasRun = false
- local CommandLabel = "FaradayMk1"
- local CommandDrive
- --Debug--
- Debug = true
- --Enderio Capacitor Bank Calculations--
- CapCount = 3269
- 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)
- if ReactorCount ~= 0 then
- i = 1
- while i <= ReactorCount do
- x = 1
- while x <= ReactorActiveCount do
- print("Actively Cooled Reactor "..x.." Connected: ", ReactorActive[x].getConnected())
- x = x + 1
- i = i + 1
- end
- y = 1
- while y <= ReactorPassiveCount do
- print("Passively Cooled Reactor "..y.." Connected: ", ReactorPassive[y].getConnected())
- y = y +1
- i = i + 1
- end
- end
- end
- sleep(3)
- shell.run("clear")
- print("Debug On")
- print("----------")
- print(" ")
- print("Turbines Connected: ", TurbineCount)
- if TurbineCount ~= 0 then
- i = 1
- while i <= TurbineCount do
- print("Turbine "..i.." Connected: ", Turbine[i].getConnected())
- i = i + 1
- end
- end
- sleep(3)
- shell.run("clear")
- print("Debug On")
- print("----------")
- print(" ")
- print("Cap. Banks Connected: ", CapConnections)
- print("Capacitor Count: ", CapCount)
- print("Capacitor Type: ", CapType)
- print("Total Capacity: ", TotalCapacity)
- print("Computers Connected: ", CompCount)
- print("Stargate Connected: ")
- sleep(3)
- 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)
- sleep(3)
- 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("Big Reactors Turbine Synced.")
- Turbine[#Turbine+1] = peripheral.wrap(b)
- TurbineCount = TurbineCount + 1
- sleep(.15)
- elseif peripheral.getType(b) == "tile_blockcapacitorbank_name" then
- print("Enderio Capacitor Bank Synced.")
- Capacitor[#Capacitor+1] = peripheral.wrap(b)
- CapConnections = CapConnections + 1
- sleep(.15)
- elseif peripheral.getType(b) == "BigReactors-Reactor" then
- print("Big Reactors Reactor Synced.")
- i = peripheral.wrap(b)
- if i.isActivelyCooled() == true then
- print("Reactor is Actively Cooled.")
- ReactorActive[#ReactorActive+1] = peripheral.wrap(b)
- ReactorCount = ReactorCount + 1
- ReactorActiveCount = ReactorActiveCount + 1
- sleep(.15)
- else
- print("Reactor is Passively Cooled.")
- ReactorPassive[#ReactorPassive + 1] = peripheral.wrap(b)
- ReactorCount = ReactorCount + 1
- ReactorPassiveCount = ReactorPassiveCount + 1
- sleep(.15)
- end
- elseif peripheral.getType(b) == "stargate" then
- print("Stargate Controller Synced.")
- Stargate = peripheral.wrap(b)
- sleep(.15)
- elseif peripheral.getType(b) == "computer" then
- print("Computer Terminal Synced.")
- Computers[#Computers+1] = peripheral.wrap(b)
- CompCount = CompCount + 1
- sleep(.15)
- elseif peripheral.getType(b) == "drive" then
- if disk.isPresent(b) == true then
- DiskLabel = disk.getLabel(b)
- if DiskLabel == CommandLabel then
- print("Command Program Identified.")
- CommandDrive = peripheral.wrap(b)
- else
- print("Unconnected Drive")
- end
- else
- print("Empty Drive.")
- end
- else
- print("Incompatible Device.")
- sleep(.15)
- end
- end
- sleep(5)
- print()
- print()
- print()
- end
- --System Start--
- function systemStart(Boot)
- if Boot == false then
- shell.run("clear")
- print("Starting Computers.")
- sleep(.15)
- print("Please Wait..")
- for a,b in pairs(Computers) do
- b.turnOn()
- sleep(.15)
- end
- Started = true
- print("All Computers Started")
- sleep(.2)
- else
- for k,v in pairs(Computers) do
- if v.isOn() == false then
- v.turnOn()
- if Debug == true then
- print("Connection Reestablished")
- end
- end
- end
- end
- end
- -- Big Reactors Turbine Spinup--
- function turbineSpinup()
- i = 1
- while i <= TurbineCount do
- Flow= Turbine[i].getFluidFlowRateMax()
- if Flow >= 1001 then
- Speed = "High"
- else
- Speed = "Low"
- end
- if Speed == "High" and Turbine[i].getRotorSpeed() < 1750 then
- Turbine[i].setInductorEngaged(false)
- elseif Speed == "Low" and Turbine[i].getRotorSpeed() < 750 then
- Turbine[i].setInductorEngaged(false)
- elseif Speed == "High" and Turbine[i].getRotorSpeed() >= 1750 then
- if Turbine[i].getInductorEngaged() == false then
- Turbine[i].setInductorEngaged(true)
- end
- elseif Speed == "Low" and Turbine[i].getRotorSpeed() >= 750 then
- if Turbine[i].getInductorEngaged() == false then
- Turbine[i].setInductorEngaged(true)
- end
- elseif Turbine[i].getRotorSpeed() == 0 then
- if Turbine[i].getInductorEngaged() == true then
- Turbine[i].setInductorEngaged(false)
- end
- end
- i =i +1
- 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
- ReactorActive[1].setAllControlRodLevels(27)
- Turbine[1].setFluidFlowRateMax(1270)
- Turbine[2].setFluidFlowRateMax(1270)
- turbineSpinup()
- elseif EnergyStored >= EmptyLevel and EnergyStored <= LowLevel then
- ReactorActive[1].setAllControlRodLevels(28)
- Turbine[1].setFluidFlowRateMax(1270)
- Turbine[2].setFluidFlowRateMax(1270)
- turbineSpinup()
- elseif EnergyStored >= LowLevel and EnergyStored <= MedLevel then
- ReactorActive[1].setAllControlRodLevels(49)
- Turbine[1].setFluidFlowRateMax(1270)
- Turbine[2].setFluidFlowRateMax(550)
- turbineSpinup()
- elseif EnergyStored >= MedLevel and EnergyStored < HighLevel then
- ReactorActive[1].setAllControlRodLevels(65)
- Turbine[1].setFluidFlowRateMax(1270)
- Turbine[2].setFluidFlowRateMax(0)
- turbineSpinup()
- elseif EnergyStored >= HighLevel and EnergyStored <= FullLevel then
- ReactorActive[1].setAllControlRodLevels(85)
- Turbine[1].setFluidFlowRateMax(550)
- Turbine[2].setFluidFlowRateMax(0)
- turbineSpinup()
- elseif EnergyStored >= FullLevel then
- ReactorActive[1].setAllControlRodLevels(100)
- Turbine[1].setFluidFlowRateMax(0)
- if Turbine[2].getFluidFlowRateMax() == 0 then
- Turbine[2].setFluidFlowRateMax(0)
- end
- turbineSpinup()
- 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 >= 0 and EnergyStored <= MedLevel then
- i = 1
- while i <= ReactorActiveCount do
- if ReactorActive[i].getActive() == false then
- ReactorActive[i].setActive(true)
- i = i + 1
- else
- i = i + 1
- end
- end
- ReactorActive[1].setAllControlRodLevels(55)
- i = 1
- while i <= TurbineCount do
- if Turbine[i].getInductorEngaged() == false then
- Turbine[i].setInductorEngaged(true)
- end
- Turbine[i].setFluidFlowRateMax(2000)
- i = i + 1
- end
- turbineSpinup()
- elseif EnergyStored >= MedLevel and EnergyStored <= FullLevel then
- ReactorActive[1].setAllControlRodLevels(69)
- i = 1
- while i <= TurbineCount do
- if Turbine[i].getInductorEngaged() == false then
- Turbine[i].setInductorEngaged(true)
- end
- Turbine[i].setFluidFlowRateMax(1000)
- i = i + 1
- end
- turbineSpinup()
- else
- ReactorActive[1].setAllControlRodLevels(100)
- i = 1
- while i <= TurbineCount do
- if Turbine[i].getInductorEngaged() == true then
- Turbine[i].setInductorEngaged(false)
- end
- i = i + 1
- end
- 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 == false then
- if not hasRun and disk.getLabel("CommandDrive")== CommandLabel then
- hasRun = not hasRun
- for k,v in pairs({peripheral.find("computer")}) do
- v.reboot() --# I think this is function name
- end
- end
- if Status == "normal" then
- normalOperation()
- systemStart(Started)
- elseif Status == "economy" then
- economy()
- systemStart(Started)
- end
- elseif evt[1] == "disk" then
- hasRun = false --# Changing hasRun back to false for the new disk
- 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
Advertisement