xavierlebel

Untitled

Mar 5th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. energyPercent = 50 -- what percentage to react on
  2. reCheckTimer = 5 -- How many seconds to wait before it checks again
  3. EnergyCellSide = "left" -- Which side of the computer the energy cell is on
  4.  
  5. enCell = peripheral.wrap(EnergyCellSide)
  6.  
  7. function getEnergy()
  8. return enCell.getEnergyStored("unknown")
  9. end
  10.  
  11. function getMaxEnergy()
  12. return enCell.getMaxEnergyStored("unkown")
  13. end
  14.  
  15. function getEnergyPercent()
  16. return math.floor(getEnergy()/getMaxEnergy()*100)
  17. end
  18.  
  19. while true do
  20. if getEnergyPercent() >= energyPercent then
  21. print ("yes")
  22. else
  23. print ("no")
  24. end
  25. sleep(reCheckTimer)
  26. end
Advertisement
Add Comment
Please, Sign In to add comment