Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c = require("component")
- r = c.br_reactor
- tList = {}
- target = 0
- controlLevel = 0
- tTotals = {}
- tTotals["steamNeed"] = 0
- tTotals["energyOutput"] = 0
- function startReactor()
- r.setActive(true)
- r.setAllControlRodLevels(0)
- 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, "getFluidFlowRate")
- 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(controlLevel)
- r.setAllControlRodLevels(controlLevel)
- end
- function tListBuild()
- for k, v in c.list("br_turbine") do
- tList[k] = {}
- tList[k]["steamUsed"] = 0
- tList[k]["isActive"] = false
- tList[k]["coilsEngaged"] = false
- tList[k]["rotorSpeed"] = 0
- tList[k]["energyOutput"] = 0
- end
- end
- function tSpeedControl()
- 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()
- while true do
- monReactor()
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment