Advertisement
AlexMastang

NC Fission Reactor Control Program (IT)

Apr 12th, 2022 (edited)
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local sides = require("sides")
  4. local reactor = component.nc_fission_reactor
  5. local rs = component.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. local function distacco(carattere)
  14.   gpu = component.gpu
  15.   local a,b = gpu.getResolution()
  16.   math.floor(a)
  17.   for i=1,a do
  18.     io.write(carattere)
  19.   end
  20. end
  21.  
  22. term.clear()
  23. term.setCursor(1, y)
  24. distacco("-")
  25. print("Lunghezza X: " .. reactor.getLengthX())
  26. print("Lunghezza Y: " .. reactor.getLengthY())
  27. print("Lunghezza Z: " .. reactor.getLengthZ())
  28. distacco("-")
  29. print("Moltiplicatore calore: " .. math.floor(reactor.getHeatMultiplier()*1)*1 .. "%")
  30. print("Celle: " .. reactor.getNumberOfCells())
  31. print("Massimo energia settata: " .. max_energy_perc .. "%")
  32. print("Minimo energia settata: " .. min_energy_perc .. "%")
  33. print("Massimo calore settato: " .. max_heat_perc .. "%")
  34. distacco("-")
  35. print("Combustibile: " .. reactor.getFissionFuelName())
  36. print("Energia combustibile: " .. reactor.getFissionFuelPower() .. " FE/t")
  37. print("Produzione reattore: " .. reactor.getReactorProcessPower() .. " FE/t")
  38. print("Tempo di decadimento combustibile base: " .. math.floor((reactor.getFissionFuelTime() / 1200)*100)/100 .. " min")
  39. print("Effettivo tempo di decadimento combustibile: " .. math.floor((reactor.getReactorProcessTime() / 1200)*100)/100 .. " min")
  40. print("Efficienza: " .. math.floor(reactor.getEfficiency()*10)/10 .. "%")
  41.  
  42. local c = 0
  43. c,y = term.getCursor()
  44. while y<17 do
  45.   y = y + 1
  46. end
  47.  
  48. while true do
  49.   heat_perc = reactor.getHeatLevel() * 100 / reactor.getMaxHeatLevel()
  50.   energy_perc = reactor.getEnergyStored() * 100 / reactor.getMaxEnergyStored()
  51.   energy_indicator = math.floor((reactor.getEnergyStored() * 11 / reactor.getMaxEnergyStored())*1)*1
  52.   rs.setOutput(sides.east, energy_indicator)
  53.  
  54.   term.setCursor(1, y)
  55.   print("Combustibile rimasto: " .. math.floor((100 - (100 * (reactor.getCurrentProcessTime() / reactor.getFissionFuelTime())))* 10) / 10 .. "%     ")
  56.   print("Livello di calore attuale: " .. reactor.getHeatLevel()/1000 .. " kH / " .. reactor.getMaxHeatLevel()/1000 .. " kH / " .. math.floor(heat_perc*10)/10 .. "%     ")
  57.   print("Livello di energia attuale: " .. reactor.getEnergyStored()/1000 .. " kFE / " .. reactor.getMaxEnergyStored()/1000 .. " kFE / " .. math.floor(energy_perc*10)/10 .. "%     ")
  58.  
  59.   if reactor.isProcessing() == true then
  60.     print("Reattore ON        ")
  61.   else
  62.     print("Reattore OFF        ")
  63.   end
  64.  
  65.   if rs.getInput(sides.top) == 0 then
  66.     reactor.deactivate()
  67.     break
  68.   end
  69.  
  70.   if heat_perc == 0 then
  71.     if energy_perc > max_energy_perc then
  72.       reactor.deactivate()
  73.       forc = true
  74.     end
  75.     if energy_perc < min_energy_perc then
  76.       reactor.activate()
  77.       forc = false
  78.     end
  79.   elseif heat_perc > max_heat_perc then
  80.     reactor.deactivate()
  81.   end
  82.   os.sleep(0.5)
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement