BigBlow_

fission_fissilFuelMeter

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