Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- turbine = peripheral.wrap("back")
- optimalRotorSpeed = 1800
- rotorVariance = 10
- maxFlowRate = 2000
- leastFlowRate = 500
- capacitor = peripheral.wrap("tile_blockcapacitorbank_name_1")
- capacitorCount = 3
- capacitorCapacity = 25000000
- totalCapacity = (capacitorCount * capacitorCapacity)
- powerVariance = 5000000
- function engage(bool)
- turbine.setInductorEngaged(bool)
- end
- function power(bool)
- turbine.setActive(bool)
- end
- function lower(cur)
- turbine.setFluidFlowRateMax((cur-100))
- end
- function higher(cur)
- turbine.setFluidFlowRateMax((cur+100))
- end
- while true do
- on = turbine.getActive()
- engaged = turbine.getInductorEngaged()
- curSpeed = turbine.getRotorSpeed()
- steamAmount = turbine.getInputAmount()
- flowRate = turbine.getFluidFlowRateMax()
- flowMax = (flowRate==maxFlowRate)
- flowLeast = (flowRate==leastFlowRate)
- rotorLow = (curSpeed<(optimalRotorSpeed-rotorVariance))
- rotorGood = (curSpeed==optimalRotorSpeed)
- rotorHigh = (curSpeed>(optimalRotorSpeed+rotorVariance))
- steamLow = (steamAmount<flowRate)
- steamHigh = (steamAmount>=flowRate)
- energy = capacitor.getEnergyStored()
- actualEnergy = (energy * capacitorCount)
- energyFull = (actualEnergy>=(totalCapacity-powerVariance))
- if on then
- if engaged then
- if rotorLow then
- if flowMax then
- engage(false)
- else
- higher(flowRate)
- sleep(1)
- end
- end
- if rotorHigh then
- lower(flowRate)
- sleep(1)
- end
- else
- if rotorGood or rotorHigh then
- engage(true)
- end
- end
- if steamLow then
- if rotorLow then
- engage(false)
- end
- if flowLeast then
- power(false)
- else
- lower(flowRate)
- end
- end
- else
- if steamHigh and not energyFull then
- power(true)
- end
- end
- if energyFull then
- power(false)
- engage(false)
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement