Advertisement
p0rt23

Untitled

Jul 23rd, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local keyboard = require("keyboard")
  4. local format = require("format")
  5.  
  6. local gpu = component.gpu
  7. local matrix = component.induction_matrix
  8. local reactor = component.reactor_logic_adapter
  9.  
  10. local function toRf(joules)
  11. return joules/2.5
  12. end
  13.  
  14. local function formatNumber(n)
  15. return format.formatNumber(toRf(n))
  16. end
  17.  
  18. local function formatPercent(n, max)
  19. if max > 0 then
  20. return format.formatNumber((n/max)*100)
  21. else
  22. return 0
  23. end
  24. end
  25.  
  26. local function getReactorStatus()
  27. if reactor.isIgnited() then
  28. return "Online"
  29. else
  30. return "Offline"
  31. end
  32. end
  33.  
  34. local function handleMatrixFull()
  35. if matrix.getEnergy() == matrix.getMaxEnergy() then
  36. if reactor.isIgnited() then
  37. reactor.setInjectionRate(0)
  38. end
  39. end
  40. end
  41.  
  42.  
  43. local matrixMaxEnergy, matrixEnergy, matrixEnergyPercent
  44. local matrixInputRate, matrixInputPercent
  45. local matrixOutputRate, matrixOutputPercent, matrixTransferCap
  46. local reactorStatus, reactorPlasmaHeatPercent, reactorProducing
  47.  
  48. local function setEnergyValues()
  49. matrixMaxEnergy = formatNumber(matrix.getMaxEnergy())
  50. matrixEnergy = formatNumber(matrix.getEnergy())
  51. matrixEnergyPercent = formatPercent(matrix.getEnergy(), matrix.getMaxEnergy())
  52. matrixInputRate = formatNumber(matrix.getInput())
  53. matrixInputPercent = formatPercent(matrix.getInput(), matrix.getTransferCap())
  54. matrixOutputRate = formatNumber(matrix.getOutput())
  55. matrixOutputPercent = formatPercent(matrix.getOutput, matrix.getTrasnsferCap())
  56.  
  57. reactorStatus = getReactorStatus()
  58. reactorPlasmaHeatPercent = formatPercent(reactor.getPlasmaHeat(), reactor.getMaxPlasmaHeat())
  59. reactorProducing = formatNumber(reactor.getProducting())
  60. end
  61.  
  62. local function printStatus()
  63. print("Max Capacity: "..matrixMaxEnergy.." RF")
  64. print("Current Capacity: "..matrixEnergy.." RF ("..matrixEnergyPercent.."%)")
  65. print()
  66. print("Input Rate: "..matrixInputRate.." RF/t".." ("..matrixInputPercent.."%)")
  67. print("Output Rate: "..matrixOutputRate.." RF/t".." ("..matrixOutputPercent.."%)")
  68. print()
  69. print("Reactor Status: "..reactorStatus)
  70. print("Reactor Heat: "..reactorPlasmaHeatPercent.."%")
  71. print("Reactor Power: "..reactorProducing.." RF/t")
  72. end
  73.  
  74. local oldW, oldH = gpu.getResolution()
  75. gpu.setResolution(40, 10)
  76.  
  77. while true do
  78. setEnergyValues()
  79. term.clear()
  80. printStatus()
  81. handleMatrixFull()
  82.  
  83. if keyboard.isControlDown() and keyboard.isKeyDown(keyboard.keys.w) then
  84. gpu.setResolution(oldW, oldH)
  85. os.exit()
  86. end
  87.  
  88. os.sleep(0.5)
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement