Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t = {}
- local energy = {}
- local engaged = {}
- local online = {}
- local rpm = {}
- local restart = 0
- function getStatus()
- for i = 0, #t - 1 do
- engaged[i] = t[i].getInductorEngaged()
- online[i] = t[i].getActive()
- energy[i] = t[i].getEnergyStored()
- rpm[i] = t[i].getRotorSpeed()
- end
- end
- function getConnectedTurbines()
- local allDone = false
- local turbine = nil
- local i = 0
- repeat
- turbine = peripheral.wrap("BigReactors-Turbine_" .. i)
- if turbine ~= nil then
- print("Hooking up turbine #" .. i)
- t[i] = turbine
- i = i + 1
- end
- allDone = turbine == nil
- until allDone
- return i
- end
- no_turbines_error = getConnectedTurbines() == 0
- if no_turbines_error then
- printError("No turbines found!")
- break
- end
- while true do
- getStatus()
- for i = 0, #t - 1 do
- t[i].setInductorEngaged(not(rpm[i] < 1780 or not (rpm[i] > 1820))) -- turn on coils when needed
- end
- restart = restart + 1
- if restart == 5 then
- os.reboot()
- else
- os.sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement