Advertisement
ryanbibby

Untitled

Jul 28th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. local reactor
  2. local storedEnergy
  3. local capacity = 10000000
  4. local onPercent = 5
  5. local offPercent = 90
  6. local currentCapacity
  7.  
  8. reactor = peripheral.wrap('back')
  9. while true do
  10.  if reactor.getConnected() then
  11.    sleep(10)
  12.    storedEnergy = reactor.getEnergyStored()
  13.    currentCapacity = (storedEnergy/capacity) * 100
  14.    print('Power at ' .. currentCapacity .. '%')
  15.    if currentCapacity > offPercent and reactor.getActive() then
  16.      reactor.setActive(false)
  17.      print('Turning reactor off')
  18.    elseif currentCapacity < onPercent and not reactor.getActive() then
  19.      reactor.setActive(true)
  20.      print('Turning reactor on')
  21.    end
  22.  end  
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement