Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local event = require("event")
  4.  
  5. if not component.isAvailable("nc_fission_reactor") then
  6. print("Reactor not connected. Please connect the computer to the fission reactor.")
  7. os.exit()
  8. end
  9.  
  10. local x , y = component.gpu.maxResolution()
  11. local x = math.min(y,24) * 2
  12. component.gpu.setResolution(x,x/2)
  13.  
  14. local reactor,MHP,WSEP,runv,help,auto,E,H,C,G = component.nc_fission_reactor,50,75,true,true,false
  15.  
  16. function run(b)
  17. if b and runv then return true
  18. else runv = false
  19. end
  20. end
  21.  
  22. function insert(table, key, content) table[key] = content end
  23. function runf() run(false) end
  24. function updatef() reactor.forceUpdate() end
  25. function autof() if auto == true then auto = false else auto = true end end
  26. function helpf() if help == true then help = false else help = true end end
  27. local keyactions = {[35]=helpf,[30]=autof,[22]=updatef,[18]=runf}
  28.  
  29. local preG = math.floor(reactor.getReactorProcessHeat())
  30. if preG > 0
  31. then G = preG
  32. else G = "None"
  33. end
  34.  
  35. local Help = {
  36. "",
  37. "Press U to call an update to all the values",
  38. "Press A to toggle Auto control : " .. tostring(auto),
  39. "Press E to exit the script",
  40. "Press H to toggle this help message",
  41. "The script is really slow so",
  42. "exept some delay on key presses"
  43. }
  44.  
  45. while run(true) do
  46.  
  47. if auto == true then
  48. SEP = reactor.getEnergyStored() / reactor.getMaxEnergyStored() * 100
  49. HP = reactor.getHeatLevel() / reactor.getMaxHeatLevel() * 100
  50. if HP > MHP or SEP > WSEP
  51. then reactor.deactivate()
  52. else reactor.activate()
  53. end
  54. end
  55.  
  56. if term.isAvailable() then
  57.  
  58. E = (math.floor(reactor.getEfficiency() * 10)) / 10
  59. H = (math.floor(reactor.getHeatMultiplier() * 10)) / 10
  60. C = math.floor(math.abs(reactor.getEnergyChange()))
  61.  
  62. if G ~= "None" then G = math.floor(reactor.getReactorProcessHeat()) end
  63.  
  64. local A = ""
  65. if reactor.isProcessing()
  66. then A = "Active"
  67. else A = "Standby"
  68. end
  69.  
  70. local L = {
  71. "" ,
  72. "" .. math.floor(reactor.getLengthX()) .. "x" .. math.floor(reactor.getLengthY()) .. "x" .. math.floor(reactor.getLengthZ()) .. " " .. A .. " Fission Reactor" ,
  73. "Fuel : " .. reactor.getFissionFuelName() ,
  74. " " .. reactor.getFissionFuelPower() .. " RF/t - " .. reactor.getFissionFuelHeat() .. " H/t",
  75. "Efficiency : " .. E .. "%" ,
  76. "Heat : " .. H .. "%" ,
  77. "Energy : " .. math.floor(reactor.getEnergyStored()) .. " / " .. math.floor(reactor.getMaxEnergyStored()) ,
  78. "Energy I/O : " .. C ,
  79. "Heat : " .. math.floor(reactor.getHeatLevel()) .. " / " .. math.floor(reactor.getMaxHeatLevel()) ,
  80. "Heat Gen : " .. G,
  81. }
  82.  
  83. term.clear()
  84.  
  85. for i, v in ipairs(L) do
  86. term.setCursor(3,i)
  87. term.write(v)
  88. end
  89.  
  90. if help == true then
  91. insert(Help,3,"Press A to toggle Auto control : " .. tostring(auto))
  92. for i,v in ipairs(Help) do
  93. term.setCursor(3,10+i)
  94. term.write(v)
  95. end
  96. end
  97.  
  98. local ev, _ , _ , v2 = event.pull(0.3)
  99. if ev == "key_up" then
  100. if keyactions[v2] ~= nil then keyactions[v2]() end
  101. end
  102. end
  103. end
  104.  
  105. reactor.deactivate()
  106. term.clear()
  107. if component.isAvailable("gpu") then
  108. component.gpu.setResolution(component.gpu.maxResolution())
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement