Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------
- --CONFIG
- ----------------------------------------
- speed = 1780
- steam = 2000
- --value in %
- reactorOn = 50
- reactorOff = 90
- ----------------------------------------
- local peripheralList = peripheral.getNames()
- amountTurbines = 0
- reactorNumber = 0
- t = {}
- r = {}
- for i = 1, #peripheralList do
- --Turbines
- if peripheral.getType(peripheralList[i]) == "BigReactors-Turbine" then
- t[amountTurbines] = peripheral.wrap(peripheralList[i])
- amountTurbines = amountTurbines + 1
- --Reactor
- elseif peripheral.getType(peripheralList[i]) == "BigReactors-Reactor" then
- r[reactorNumber] = peripheral.wrap(peripheralList[i])
- reactorNumber = reactorNumber + 1
- --Monitor & Touchpoint
- elseif peripheral.getType(peripheralList[i]) == "monitor" then
- mon = peripheral.wrap(peripheralList[i])
- touchpointLocation = peripheralList[i]
- --Capacitorbank / Energycell / Energy Core
- else
- local tmp = peripheral.wrap(peripheralList[i])
- local stat,err = pcall(function() tmp.getEnergyStored() end)
- if stat then
- v = tmp
- end
- end
- end
- mon.setTextColor(colors.white)
- mon.setTextScale(1)
- term.setTextColor(colors.white)
- local a = 1
- while a < amountTurbines do
- for i = 0, amountTurbines-1 do
- local tspeed = t[i].getRotorSpeed()
- if tspeed <= speed then
- for j = 0, reactorNumber-1 do
- r[j].setActive(true)
- end
- t[i].setActive(true)
- t[i].setInductorEngaged(false)
- t[i].setFluidFlowRateMax(steam)
- end
- if t[i].getRotorSpeed() > speed then
- t[i].setFluidFlowRateMax(0)
- end
- end
- a = 0
- mon.clear()
- mon.setCursorPos(1,1)
- term.clear()
- term.setCursorPos(1,1)
- for i = 0, amountTurbines-1 do
- b = i+1
- mon.setTextColor(colors.white)
- if t[i].getRotorSpeed() <= speed then
- term.setTextColor(colors.red)
- print("["..b.."]".." "..math.floor(t[i].getRotorSpeed()))
- end
- if t[i].getRotorSpeed() > speed then
- a = a+1
- end
- end
- sleep(1)
- end
- mon.setTextColor(colors.white)
- term.setTextColor(colors.white)
- for j = 0, reactorNumber-1 do
- r[j].setActive(false)
- end
- for i = 0, amountTurbines-1 do
- t[i].setInductorEngaged(false)
- t[i].setFluidFlowRateMax(0)
- end
- mon.clear()
- mon.setTextScale(5)
- mon.setCursorPos(1,2)
- term.clear()
- term.setCursorPos(1,1)
- mon.setTextColor(colors.red)
- term.setTextColor(colors.red)
- mon.write("off")
- term.write("off")
- while true do
- local procent = v.getEnergyStored()/v.getMaxEnergyStored()*100
- if procent <= reactorOn then
- mon.clear()
- mon.setCursorPos(1,2)
- term.clear()
- term.setCursorPos(1,1)
- mon.setTextColor(colors.green)
- term.setTextColor(colors.green)
- mon.write("on")
- term.write("on")
- for i = 0, reactorNumber-1 do
- r[i].setActive(true)
- end
- sleep(5)
- for i = 0, amountTurbines-1 do
- t[i].setActive(true)
- t[i].setInductorEngaged(true)
- t[i].setFluidFlowRateMax(steam)
- end
- elseif procent >= reactorOff then
- mon.clear()
- mon.setCursorPos(1,2)
- term.clear()
- term.setCursorPos(1,1)
- mon.setTextColor(colors.red)
- term.setTextColor(colors.red)
- mon.write("off")
- term.write("off")
- for i = 0, amountTurbines-1 do
- t[i].setInductorEngaged(false)
- t[i].setFluidFlowRateMax(0)
- end
- for j = 0, reactorNumber-1 do
- r[j].setActive(false)
- end
- end
- mon.setCursorPos(1,1)
- mon.setTextScale(5)
- mon.setTextColor(colors.blue)
- mon.write(math.floor(procent).."%")
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement