Advertisement
tbrixey

Super Basic Bigger Reactor Monitor Minecraft

Oct 9th, 2022 (edited)
1,659
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. allNames = peripheral.getNames()
  2.  
  3. function getReactorName()
  4.     for x = 1, #allNames do
  5.         if string.match(allNames[x], "_Reactor_") then
  6.             return allNames[x]
  7.         end
  8.     end
  9. end
  10.  
  11. reactorName = getReactorName()
  12.  
  13. if reactorName == nil then
  14.     write("Can't find 'Bigger Reactors' reactor")
  15.     exit()
  16. else
  17.     write("Found reactor\n")
  18. end
  19.  
  20. reactor = peripheral.wrap(reactorName)
  21.  
  22. function monitorPower()
  23.     while true do
  24.         currentRodPercent = reactor.getControlRod(0).level()
  25.         batteryLevel = reactor.battery().stored() / reactor.battery().capacity()
  26.         batteryLevelRounded = batteryLevel * 100
  27.         batteryLevelRounded = math.floor(batteryLevelRounded)
  28.  
  29.         if batteryLevelRounded > 90 then
  30.             reactor.setActive(false)
  31.             write("Battery level over 90%, reactor off.\n")
  32.         else
  33.            reactor.setActive(true)
  34.            write("Battery level: " .. batteryLevelRounded .. "%\n")
  35.         end
  36.        
  37.         sleep(30)
  38.     end
  39. end
  40.  
  41. monitorPower()
Advertisement
Comments
  • tbrixey
    2 years
    # text 0.09 KB | 0 0
    1. I don't know if this works yet. Will update with a new comment when I verify that it works.
    • tbrixey
      2 years
      # text 0.12 KB | 0 0
      1. Should be good now! Just use this with a bigger reactor and it'll simply turn it off and on based on it's internal buffer.
Add Comment
Please, Sign In to add comment
Advertisement