Advertisement
Alakazard12

Reactor Controller

Aug 1st, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. local capacitor = peripheral.find("tile_blockcapacitorbank_name")
  2. if not capacitor then
  3.     error("no capacitor found", 0)
  4.     return
  5. end
  6. local reactor = peripheral.find("BigReactors-Reactor")
  7. if not reactor then
  8.     error("no reactor found", 0)
  9.     return
  10. end
  11.  
  12. local minimum = 1000000 -- if the capacitor has less than this amount of energy, the reactor will power on
  13. local maximum = 1000000 -- if the capacitor has the maximum amount of energy minus this, the reactor will power off
  14.  
  15. while true do
  16.     local eMax = capacitor.getMaxEnergyStored()
  17.     local eStored = capacitor.getEnergyStored()
  18.     if eStored < minimum then
  19.         reactor.setActive(true)
  20.     end
  21.     if eStored > eMax - maximum then
  22.         reactor.setActive(false)
  23.     end
  24.  
  25.     sleep(5)
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement