MrDj200

batteryStatus

Apr 4th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. cableSide   = "back"
  2. energyCell  = "right"
  3. p = peripheral.wrap(energyCell)
  4.  
  5.  
  6. function green()
  7.     rs.setBundledOutput(cableSide, colors.green+colors.yellow+colors.orange+colors.red)
  8. end
  9.  
  10. function yellow()
  11.     rs.setBundledOutput(cableSide, colors.yellow+colors.orange+colors.red)
  12. end
  13.  
  14. function orange()
  15.     rs.setBundledOutput(cableSide, colors.orange+colors.red)
  16. end
  17.  
  18. function red()
  19.     rs.setBundledOutput(cableSide, colors.red)
  20. end
  21.  
  22. while true do
  23.     mom = p.getEnergyStored(energyCell)
  24.     max = p.getMaxEnergyStored(energyCell)
  25.     y = max*0.75
  26.     o = max*0.50
  27.     r = max*0.25
  28.     if mom > y then
  29.         green()
  30.     elseif mom > o then
  31.         yellow()
  32.     elseif mom > r then
  33.         orange()
  34.     else
  35.         red()
  36.     end
  37.     while mom==0 do
  38.         mom = p.getEnergyStored(energyCell)
  39.         green()
  40.         sleep(0.5)
  41.         rs.setBundledOutput(cableSide, 0)
  42.         sleep(0.5)
  43.     end
  44.     sleep(0.1)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment