Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c = require("component")
- r = c.br_reactor
- tList = {}
- controlLevel = 50
- tTotals = {}
- tTotals["steamNeed"] = 0
- tTotals["energyOutput"] = 0
- targetSpeed = 1800
- function startReactor()
- r.setActive(true)
- r.setAllControlRodLevels(50)
- end
- function startTurbine()
- tListBuild()
- for k, v in pairs(tList) do
- c.invoke(k, "setActive", true)
- c.invoke(k, "setInductorEngaged", false)
- c.invoke(k, "setFluidFlowRateMax", 1000)
- end
- end
- function updateTotals()
- tTotals["steamNeed"] = 0
- for k, v in pairs(tList) do
- tTotals["steamNeed"] = tTotals["steamNeed"] + c.invoke(k, "getFluidFlowRateMax")
- tTotals["energyOutput"] = tTotals["energyOutput"] + c.invoke(k, "getEnergyProducedLastTick")
- end
- print("steam needed " .. tostring(tTotals["steamNeed"]))
- end
- function monReactor()
- updateTotals()
- if r.getHotFluidProducedLastTick() < tTotals["steamNeed"] then
- if controlLevel > 0 then controlLevel = controlLevel - 1 end
- else
- if controlLevel < 100 then controlLevel = controlLevel + 1 end
- end
- print(r.getContolRodLevel(1)
- r.setAllControlRodLevels(controlLevel)
- end
- function tListBuild()
- for k, v in c.list("br_turbine") do
- tList[k] = {}
- tList[k]["steamUsed"] = c.invoke(k, "getFluidFlowRateMax")
- tList[k]["isActive"] = false
- tList[k]["coilsEngaged"] = false
- tList[k]["rotorSpeed"] = 0
- tList[k]["energyOutput"] = 0
- end
- end
- function tSpeedControl()
- for k, v in pairs(tList) do
- tList[k]["rotorSpeed"] = c.invoke(k, "getRotorSpeed")
- if tList[k]["rotorSpeed"] > 1800 and tList[k]["rotorSpeed"] < 1810 then
- tList[k]["steamUsed"] = tList[k]["steamUsed"] - 1
- c.invoke(k, "setFluidFlowRateMax", tList[k]["steamUsed"])
- elseif tList[k]["rotorSpeed"] > 1900 then
- tList[k]["steamUsed"] = tList[k]["steamUsed"] - 10
- c.invoke(k, "setFluidFlowRateMax", tList[k]["steamUsed"])
- elseif tList[k]["rotorSpeed"] < 1800 and tList[k]["rotorSpeed"] > 1790 then
- tList[k]["steamUsed"] = tList[k]["steamUsed"] + 1
- c.invoke(k, "setFluidFlowRateMax", tList[k]["steamUsed"])
- elseif tList[k]["rotorSpeed"] < 1700 then
- tList[k]["steamUsed"] = tList[k]["steamUsed"] + 10
- c.invoke(k, "setFluidFlowRateMax", tList[k]["steamUsed"])
- end
- end
- end
- function tListData()
- for k, v in pairs(tList) do
- for l, b in pairs(tList[k]) do
- print(tList[k][l])
- end
- end
- end
- --Main code block
- startTurbine()
- for i = 1,200 do
- monReactor()
- tSpeedControl()
- os.sleep(0.1)
- end
- for i = 1,200 do
- monReactor()
- tSpeedControl()
- os.sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment