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 = economy
- 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)
- 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.getActive == false then
- b.turnOn()
- if Debug == true then
- print("Computer Check Complete")
- 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--
- --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) --# starting a timer to fire after 5 seconds
- local evt = {os.pullEvent()} --# catching the events and all the parameters in a table
- if evt[1] == "timer" and evt[2] == myTimer and on then --# checking to see if the event is a "timer" event, and checking if the timer event is one we are looking for, I will explain "on" below
- --# this is essentially replacing the sleep that you had at the end of your original code
- normalOperation()
- elseif evt[1] == "disk" then
- --# a disk was just added to the system
- local computers = peripheral.find("computer")
- for k,v in pairs(computers) do --# begin looping through and turning on all computers
- v.turnOn()
- end
- on = true --# i will explain the importance of this below
- elseif evt[1] == "disk_eject" then
- --# a disk was just removed from the system
- local computers = peripheral.find("computer")
- for k,v in pairs("computer") do --# begin looping through and turning off all computers
- v.shutdown()
- end
- on = false --# I will explain the importance of this below
- end
- os.stopTimer(myTimer) --# I will further explain this below
- end
Advertisement
Add Comment
Please, Sign In to add comment