Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONFIGURATION
- local testDuration = 3600 -- Maximum duration of the test in seconds
- local stopThreshold = 98 -- Stop test early if fuel fill reaches this percentage
- local updateInterval = 5 -- Interval between status updates (seconds)
- -- SCAN REACTOR
- local reactor = peripheral.find("fissionReactorLogicAdapter")
- if not reactor then
- print("Error: reactor not found")
- return
- end
- -- MEASURE INPUT RATE (verbose)
- local function measureFuelInputRate(maxDuration, stopPercent)
- local startFuelData = reactor.getFuel()
- local startFuel = startFuelData.amount or 0
- local startPercent = (reactor.getFuelFilledPercentage() or 0) * 100
- local startTime = os.clock()
- print("Starting fissile fuel input test...")
- print(string.format("Start fuel: %.1f mB (%.2f%%)", startFuel, startPercent))
- while true do
- local currentPercent = (reactor.getFuelFilledPercentage() or 0) * 100
- local elapsed = os.clock() - startTime
- print(string.format("[+%.1fs] Current fuel level: %.2f%%", elapsed, currentPercent))
- if currentPercent >= stopPercent then
- print(string.format("Stopping early: Fuel level reached %.2f%% (threshold: %d%%)", currentPercent, stopPercent))
- break
- end
- if elapsed >= maxDuration then
- print(string.format("Stopping: Test duration reached %.1f seconds", maxDuration))
- break
- end
- sleep(updateInterval)
- end
- local endTime = os.clock()
- local endFuelData = reactor.getFuel()
- local endFuel = endFuelData.amount or 0
- local endPercent = (reactor.getFuelFilledPercentage() or 0) * 100
- local delta = endFuel - startFuel
- local duration = endTime - startTime
- local ratePerSecond = delta / duration
- local ratePerTick = ratePerSecond / 20
- print("Test complete.")
- print(string.format("Start fuel: %.1f mB (%.2f%%)", startFuel, startPercent))
- print(string.format("End fuel: %.1f mB (%.2f%%)", endFuel, endPercent))
- print(string.format("Total input: %.1f mB over %.1f seconds", delta, duration))
- print(string.format("Average input rate: %.2f mB/tick", ratePerTick))
- return ratePerTick, delta, duration
- end
- -- MAIN
- measureFuelInputRate(testDuration, stopThreshold)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement