AlexMastang

NC Fission Reactor Control Program (EN/US)

Apr 12th, 2022 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.57 KB | None | 0 0
  1. local comp = require("component")
  2. local term = require("term")
  3. local sides = require("sides")
  4. local reactor = comp.nc_fission_reactor
  5. local rs = comp.redstone
  6. local max_energy_perc = 95
  7. local min_energy_perc = 20
  8. local max_heat_perc = 80
  9. local y = 1
  10.  
  11. reactor.activate()
  12.  
  13. term.clear()
  14. term.setCursor(1, y)
  15. print("---------------------------")
  16. print("Length X: " .. reactor.getLengthX())
  17. print("Length Y: " .. reactor.getLengthY())
  18. print("Length Z: " .. reactor.getLengthZ())
  19. print("---------------------------")
  20. print("Heat Multiplier: " .. math.floor(reactor.getHeatMultiplier()*1)*1 .. "%")
  21. print("Cells: " .. reactor.getNumberOfCells())
  22. print("Max energy range: " .. max_energy_perc .. "%")
  23. print("Min energy range: " .. min_energy_perc .. "%")
  24. print("Max heat range: " .. max_heat_perc .. "%")
  25. print("---------------------------")
  26. print("Fuel: " .. reactor.getFissionFuelName())
  27. print("Fuel energy: " .. reactor.getFissionFuelPower() .. " FE/t")
  28. print("Reactor production: " .. reactor.getReactorProcessPower() .. " FE/t")
  29. print("Fuel depletion time: " .. math.floor((reactor.getFissionFuelTime() / 1200)*100)/100 .. " min")
  30. print("Actual fuel depletion time: " .. math.floor((reactor.getReactorProcessTime() / 1200)*100)/100 .. " min")
  31. print("Efficiency: " .. math.floor(reactor.getEfficiency()*10)/10 .. "%")
  32.  
  33. y = y + 17
  34.  
  35. while true do
  36.   heat_perc = reactor.getHeatLevel() * 100 / reactor.getMaxHeatLevel()
  37.   energy_perc = reactor.getEnergyStored() * 100 / reactor.getMaxEnergyStored()
  38.   term.setCursor(1, y)
  39.   term.clearLine()
  40.   print("Fuel remaining: " .. math.floor((100 - (100 * (reactor.getCurrentProcessTime() / reactor.getFissionFuelTime())))* 10) / 10 .. "%")
  41.   term.clearLine()
  42.   print("Current heat level: " .. reactor.getHeatLevel()/1000 .. " / " .. reactor.getMaxHeatLevel()/1000 .. " kH" .. " / " .. math.floor(heat_perc*10)/10 .. "%")
  43.   term.clearLine()
  44.   print("Current energy level: " .. reactor.getEnergyStored()/1000 .. " / " .. reactor.getMaxEnergyStored()/1000 .. " kFE" .. " / " .. math.floor(energy_perc*10)/10 .. "%")
  45.  
  46.   if rs.getInput(sides.top) ~= 0 then
  47.     reactor.deactivate()
  48.     break
  49.   end
  50.  
  51.   if heat_perc == 0 then
  52.     if reactor.isProcessing() == true then
  53.       term.clearLine()
  54.       print("Reactor ON")
  55.     else
  56.       term.clearLine()
  57.       print("Reactor OFF")
  58.     end
  59.     if energy_perc > max_energy_perc then
  60.       reactor.deactivate()
  61.     end
  62.     if energy_perc < min_energy_perc then
  63.       reactor.activate()
  64.     end
  65.   elseif heat_perc > max_heat_perc then
  66.     reactor.deactivate()
  67.   end
  68.  
  69.   os.sleep(0.5)
  70.  
  71. end
Add Comment
Please, Sign In to add comment