Advertisement
BigBlow_

fission_fissilFuelMeter

Jul 8th, 2025 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. -- CONFIGURATION
  2. local testDuration = 3600  -- Maximum duration of the test in seconds
  3. local stopThreshold = 98 -- Stop test early if fuel fill reaches this percentage
  4. local updateInterval = 5 -- Interval between status updates (seconds)
  5.  
  6. -- SCAN REACTOR
  7. local reactor = peripheral.find("fissionReactorLogicAdapter")
  8. if not reactor then
  9.   print("Error: reactor not found")
  10.   return
  11. end
  12.  
  13. -- MEASURE INPUT RATE (verbose)
  14. local function measureFuelInputRate(maxDuration, stopPercent)
  15.   local startFuelData = reactor.getFuel()
  16.   local startFuel = startFuelData.amount or 0
  17.   local startPercent = (reactor.getFuelFilledPercentage() or 0) * 100
  18.   local startTime = os.clock()
  19.  
  20.   print("Starting fissile fuel input test...")
  21.   print(string.format("Start fuel: %.1f mB (%.2f%%)", startFuel, startPercent))
  22.  
  23.   while true do
  24.     local currentPercent = (reactor.getFuelFilledPercentage() or 0) * 100
  25.     local elapsed = os.clock() - startTime
  26.  
  27.     print(string.format("[+%.1fs] Current fuel level: %.2f%%", elapsed, currentPercent))
  28.  
  29.     if currentPercent >= stopPercent then
  30.       print(string.format("Stopping early: Fuel level reached %.2f%% (threshold: %d%%)", currentPercent, stopPercent))
  31.       break
  32.     end
  33.  
  34.     if elapsed >= maxDuration then
  35.       print(string.format("Stopping: Test duration reached %.1f seconds", maxDuration))
  36.       break
  37.     end
  38.  
  39.     sleep(updateInterval)
  40.   end
  41.  
  42.   local endTime = os.clock()
  43.   local endFuelData = reactor.getFuel()
  44.   local endFuel = endFuelData.amount or 0
  45.   local endPercent = (reactor.getFuelFilledPercentage() or 0) * 100
  46.  
  47.   local delta = endFuel - startFuel
  48.   local duration = endTime - startTime
  49.   local ratePerSecond = delta / duration
  50.   local ratePerTick = ratePerSecond / 20
  51.  
  52.   print("Test complete.")
  53.   print(string.format("Start fuel: %.1f mB (%.2f%%)", startFuel, startPercent))
  54.   print(string.format("End fuel:   %.1f mB (%.2f%%)", endFuel, endPercent))
  55.   print(string.format("Total input: %.1f mB over %.1f seconds", delta, duration))
  56.   print(string.format("Average input rate: %.2f mB/tick", ratePerTick))
  57.  
  58.   return ratePerTick, delta, duration
  59. end
  60.  
  61. -- MAIN
  62. measureFuelInputRate(testDuration, stopThreshold)
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement