Advertisement
Guest User

gencheck

a guest
Sep 2nd, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local side = "back"
  2. local generator = peripheral.wrap(side)
  3.  
  4. function getStored()
  5.   return(generator.getEnergyStored("top"))
  6. end
  7.  
  8. function getMax()
  9.   return(generator.getMaxEnergyStored("top"))
  10. end
  11.  
  12. function showPct()
  13.   local cur = getStored()
  14.   local maxStored = getMax()
  15.   local pct = math.floor(100 * cur / maxStored)
  16.  
  17.   return(pct.."%")
  18. end
  19.  
  20.  
  21. redstone.setOutput(side, false)
  22. while(getStored() < getMax())
  23. do
  24.   print(os.time())
  25.   print("Charging "..showPct())
  26.   sleep(1)
  27. end
  28.  
  29. redstone.setOutput(side, true)
  30. while(getStored() > 0)
  31. do
  32.   showPct()
  33.   print("Emitting "..showPct())
  34.   sleep(1)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement