Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t = peripheral.find("turbine")
- local r = peripheral.find("fissionReactor")
- local i = peripheral.find("inductionMatrix")
- local m = peripheral.find("monitor")
- local onCooldown = false
- local energyFull = false
- local function nothing()
- end
- local function formatNumber(count, aNumber)
- return ("%0." .. count .. "f"):format(aNumber)
- end
- local function formatBigNumber(work, append, sizes)
- if (work == 0) then return work .. append end
- local i = math.floor(math.log(work) / math.log(1000)) + 1
- return tostring(string.format("%0.2f", (work / 1000 ^ (i - 1)))) .. sizes[i] .. append
- end
- local function formatEnergy(num)
- return formatBigNumber(num, "fe", {"","K","M","G","T"})
- end
- local function formatLiquid(num)
- return formatBigNumber(num, "B", {"m","","K","M","G"})
- end
- while (true)
- do
- sleep(1);
- -- induction
- local inductionEnergyPct = i.getEnergyFilledPercentage()
- local inductionEnergy = i.getEnergy()
- local inductionEnergyMax = i.getMaxEnergy()
- -- reactor
- local reactorSteamPct = r.getHeatedCoolantFilledPercentage()
- local reactorSteam = r.getHeatedCoolant().amount
- local reactorCoolantPct = r.getCoolantFilledPercentage()
- local reactorCoolant = r.getCoolant().amount
- local reactorTemp = r.getTemperature()
- local reactorBurnRate = r.getBurnRate()
- local reactorStatus = r.getStatus()
- -- turbine
- local turbineSteamPct = t.getSteamFilledPercentage()
- local turbineSteam = t.getSteam()
- local turbineEnergyProd = t.getProductionRate()
- local desiredAction = r.activate -- r.activate, r.scram, nothing
- if (inductionEnergyPct > 0.95 and not energyFull)
- then
- desiredAction = r.scram
- energyFull = true
- end
- if (inductionEnergyPct < 0.1 and energyFull)
- then
- desiredAction = r.activate
- energyFull = false
- end
- if (reactorSteamPct > 0.9 or reactorCoolantPct < 0.1 and not onCooldown)
- then
- desiredAction = r.scram
- onCooldown = true
- end
- if (reactorSteamPct < 0.9 and reactorCoolantPct > 0.9 and onCooldown)
- then
- desiredAction = r.activate
- onCooldown = false
- end
- desiredAction()
- m.clear()
- m.setCursorPos(1, 1)
- m.write("Energy stored: " .. formatNumber(2, inductionEnergyPct * 100) .. "%")
- m.setCursorPos(1, 2)
- m.write(" " .. formatEnergy(inductionEnergy) .. " / " .. formatEnergy(inductionEnergyMax))
- m.setCursorPos(1, 4)
- m.write("Reactor burnrate:" .. reactorBurnRate .. "mB/t")
- m.setCursorPos(1, 5)
- m.write("Reactor coolant: " .. formatNumber(2, reactorCoolantPct * 100) .. "% (" .. formatLiquid(reactorCoolant) .. ")")
- m.setCursorPos(1, 6)
- m.write("Reactor steam: " .. formatNumber(2, reactorSteamPct * 100) .. "% (" .. formatLiquid(reactorSteam) .. ")")
- m.setCursorPos(1, 7)
- m.write("Reactor temp: " .. formatNumber(2, reactorTemp) .. "K")
- m.setCursorPos(1, 9)
- m.write("Turbine prod: " .. formatEnergy(turbineEnergyProd) .. "")
- m.setCursorPos(1, 10)
- m.write("Turbine steam: " .. formatNumber(2, turbineSteamPct * 100) .. "% (" .. formatLiquid(turbineSteam) .. ")")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement