Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. local component = require("component")
  2. local keyboard = require("keyboard")
  3. local event = require("event")
  4. local gpu = component.gpu
  5. local reactor = component.br_reactor
  6.  
  7. -- defninitions
  8. reactor["stats"] = {}
  9. local running = true
  10. local maxRF = 75
  11. local minRF = 25
  12. local currentRF = 0
  13.  
  14.  
  15. local minPowerRod = 0
  16. local maxPowerRod = 100
  17.  
  18.  
  19. -- functions
  20. function toint(n)
  21. local s = tostring(n)
  22. local i, j = s:find('%.')
  23. if i then
  24. return tonumber(s:sub(1, i-1))
  25. else
  26. return n
  27. end
  28. end
  29.  
  30. function getInfoFromReactor()
  31. local reactorEnergyStats = reactor.getEnergyStats()
  32. local reactorFuelStats = reactor.getFuelStats()
  33. reactorRodsLevel = reactor.getControlRodsLevels()
  34.  
  35. reactor.stats["tick"] = toint(math.ceil(reactorEnergyStats["energyProducedLastTick"]))
  36. reactor.stats["stored"] = toint(reactorEnergyStats["energyStored"])
  37. reactor.stats["rods"] = toint(reactorRodsLevel[0])
  38. reactor.stats["fuel"] = round(reactorFuelStats["fuelConsumedLastTick"], 2)
  39. currentRf = reactor.stats["stored"]
  40. end
  41.  
  42. function powerOn()
  43. reactor.setActive(true)
  44. end
  45.  
  46. function powerOff()
  47. reactor.setActive(false)
  48. end
  49.  
  50. -- helpers
  51. function round(val, decimal)
  52. if (decimal) then
  53. return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
  54. else
  55. return math.floor(val+0.5)
  56. end
  57. end
  58.  
  59. function Initialisation()
  60. getInfoFromReactor()
  61. for k, v in reactor.stats do
  62. print(k, v)
  63. end
  64.  
  65. --while event.pull(0.1, "interrupted") == nil do
  66.  
  67. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement