Advertisement
tsargothruneclaw

Reactor Control

May 7th, 2022 (edited)
1,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. -- Set peripheral wrapping
  2.  
  3. local Reactor = peripheral.wrap("BiggerReactors_Reactor_0")
  4. -- local Turbine = peripheral.wrap("BigReactors-Turbine_0")
  5. local Battery = peripheral.wrap("integrateddynamics:energy_battery_0")
  6.  
  7. -- Constants
  8. -- for i,k in ipairs(peripheral.getMethods("BiggerReactors_Reactor_0")) do
  9. --   print (i..":"..k)
  10. --end
  11. --for i,k in ipairs(peripheral.getMethods("integrateddynamics:energy_battery_0")) do
  12. --   print (i..":"..k)
  13. --end
  14.  
  15.  
  16. function checkBattery()
  17.  
  18.     local MaxBatt=Battery.getEnergyCapacity()
  19.     local CurBatt=Battery.getEnergy()
  20.     local BattPercent= (CurBatt / MaxBatt) * 100
  21.  
  22.     return BattPercent
  23. end
  24.  
  25. Reactor.setActive(true)
  26. print ("Starting up\nBringing Reactor online")
  27.  
  28. while true do
  29. sleep(10)
  30.  
  31.     if (Reactor.active() and checkBattery()>95) then
  32.         Reactor.setActive(false)
  33.         print ("Battery near capacity. Shutting Reactor down.")
  34.     end
  35.     if ((not Reactor.active()) and checkBattery()<10) then
  36.         Reactor.setActive(true)
  37.         print ("Battery low. Bringing Reactor online.")
  38.     end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement