Advertisement
mstiles92

Untitled

May 31st, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. wired = peripheral.wrap("back")
  2. leftCell = peripheral.wrap("left")
  3. rightCell = peripheral.wrap("right")
  4.  
  5. function request(amount)
  6.     local cons = wired.getNamesRemote()
  7.     for k, v in pairs(cons) do
  8.         local pipe = peripheral.wrap(v)
  9.         if pipe then
  10.             local id = pipe.getAvailableItems()[1][1]
  11.             pipe.makeRequest(id, amount)
  12.         end
  13.     end
  14.     sleep(1250)
  15. end
  16.  
  17. function checkEnergy(threshold)
  18.     local leftPercent = leftCell.getEnergyStored("left") / leftCell.getMaxEnergyStored("left")
  19.     local rightPercent = rightCell.getEnergyStored("right") / rightCell.getMaxEnergyStored("right")
  20.  
  21.     if leftPercent < threshold or rightPercent < threshold then
  22.         request(1)
  23.     end
  24. end
  25.  
  26. while true do
  27.     checkEnergy(0.95)
  28.     sleep(5)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement