Clem105

Energy handle

Mar 11th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.44 KB | None | 0 0
  1. p = peripheral.getNames()
  2. for i=1,#p do
  3.     tab[i] = peripheral.wrap(p[i])
  4.     if p[i] == "top" then
  5.         chest = peripheral.wrap(p[i])
  6.     end
  7. end
  8.  
  9. while true do
  10.     sum = 0
  11.     stored = 0
  12.     for o=1,#tab do
  13.         if peripheral.getType(tab[o]) ~= "ender_chest" then
  14.         sum = sum + tab[o].getMaxEnergyStored()
  15.         stored = stored + tab[o].getEnergyStored()
  16.     end
  17.     if (stored/sum)<0.5 then
  18.         chest.pushItem("north",1,1)
  19.         sleep(120)
  20.     end
  21.     sleep(5)
  22. end
Advertisement
Add Comment
Please, Sign In to add comment