Advertisement
Guest User

startup

a guest
May 25th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local side_capacitor = 'left'
  2. local conduit = 'top'
  3.  
  4. local cell = peripheral.wrap(side_capacitor)
  5. -- print(cell.listMethods())
  6.  
  7. local min = 95
  8. local max = 99
  9. local max_store = cell.getMaxEnergyStored()
  10.  
  11.  
  12. rs.setOutput(conduit, false)
  13. local working = true
  14. print 'ON'
  15.  
  16. while true do
  17.   local store = cell.getEnergyStored()
  18.   local perc = store/max_store * 100
  19.   print(perc)
  20.   if working then
  21.     if perc >= max then
  22.       rs.setOutput(conduit, true)
  23.       working = false
  24.       print 'off'
  25.     else
  26.       rs.setOutput(conduit, false)
  27.     end
  28.   else
  29.     if perc <= min then
  30.       rs.setOutput(conduit, false)
  31.       working = true
  32.       print 'on'
  33.     else
  34.       rs.setOutput(conduit, true)
  35.     end
  36.   end
  37.   os.sleep(5)
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement