Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while true do
- function comma_value (num)
- assert (type (num) == "number" or
- type (num) == "string")
- local result = ""
- -- split number into 3 parts, eg. -1234.545e22
- -- sign = + or -
- -- before = 1234
- -- after = .545e22
- local sign, before, after =
- string.match (tostring (num), "^([%+%-]?)(%d*)(%.?.*)$")
- -- pull out batches of 3 digits from the end, put a comma before them
- while string.len (before) > 3 do
- result = "," .. string.sub (before, -3, -1) .. result
- before = string.sub (before, 1, -4) -- remove last 3 digits
- end -- while
- -- we want the original sign, any left-over digits, the comma part,
- -- and the stuff after the decimal point, if any
- return sign .. before .. result .. after
- end -- function commas
- local reactorCount = 50;
- local reactors = {}
- local energyCore = peripheral.wrap("draconic_storage_1")
- local powerPercent = (energyCore.getEnergyStored() / energyCore.getMaxEnergyStored()) * 100
- local totalFuelHeat = 0
- local totalCaseHeat = 0
- local tELT = 0
- local totalFR = 0
- for i=1, reactorCount, 1 do
- reactors[i] = peripheral.wrap("BigReactors-Reactor_" .. (i - 1))
- end
- local reactorsOnline = 0
- for i, reactor in ipairs(reactors) do
- if (reactor.getActive()) then
- reactorsOnline = reactorsOnline + 1
- end
- totalFuelHeat = totalFuelHeat + reactor.getFuelTemperature()
- totalCaseHeat = totalCaseHeat + reactor.getCasingTemperature()
- tELT = tELT + reactor.getEnergyProducedLastTick()
- totalFR = totalFR + reactor.getFuelReactivity()
- if (powerPercent < 90) then
- reactor.setActive(true)
- else
- reactor.setActive(false)
- end
- end
- local m = peripheral.wrap("monitor_5")
- local avgFuelHeat = (totalFuelHeat / reactorsOnline)
- local avgCaseHeat = (totalCaseHeat / reactorsOnline)
- local elt = tELT
- local avgFR = (totalFR / reactorsOnline)
- m.clear()
- m.setTextScale(2)
- --Online Status
- m.setCursorPos(1,1)
- m.setTextColor(colors.white)
- m.write("Online: ")
- if (reactorsOnline < 1) then
- m.setTextColor(colors.red)
- else
- m.setTextColor(colors.lime)
- end
- m.write(comma_value(reactorsOnline))
- --Energy/t
- m.setCursorPos(1,2)
- m.setTextColor(colors.white)
- m.write("Energy Produced last Tick: ")
- if (elt < 5000) then
- m.setTextColor(colors.red)
- else
- m.setTextColor(colors.lime)
- end
- m.write(comma_value(math.floor(elt)) .. " RF/t")
- --Average Fuel Temp
- m.setCursorPos(1,3)
- m.setTextColor(colors.white)
- m.write("Average Fuel Temp: ")
- if (avgFuelHeat > 2000) then
- m.setTextColor(colors.red)
- else
- m.setTextColor(colors.lime)
- end
- m.write(comma_value(math.floor(avgFuelHeat)) .. " C")
- --Average Casing Temp
- m.setCursorPos(1,4)
- m.setTextColor(colors.white)
- m.write("Average Casing Temp: ")
- if (avgCaseHeat > 2000) then
- m.setTextColor(colors.red)
- else
- m.setTextColor(colors.lime)
- end
- m.write(comma_value(math.floor(avgCaseHeat)) .. " C")
- --fuelReactity
- m.setCursorPos(1,5)
- m.setTextColor(colors.white)
- m.write("Average Fuel Reactivity: ")
- if (avgFR < 250) then
- m.setTextColor(colors.red)
- else
- m.setTextColor(colors.lime)
- end
- m.write(comma_value(math.floor(avgFR)) .. "%")
- --power percent
- m.setCursorPos(1,7)
- m.setTextColor(colors.white)
- m.write("Current Energy: ")
- if (powerPercent < 25) then
- m.setTextColor(colors.red)
- elseif (powerPercent >= 25 and powerPercent < 50) then
- m.setTextColor(colors.orange)
- elseif (powerPercent >= 50 and powerPercent < 75) then
- m.setTextColor(colors.yellow)
- else
- m.setTextColor(colors.lime)
- end
- m.write(comma_value(math.floor(energyCore.getEnergyStored())).." RF, "..math.floor(powerPercent).."%")
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment