Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wired = peripheral.wrap("back")
- leftCell = peripheral.wrap("left")
- rightCell = peripheral.wrap("right")
- function request(amount)
- local cons = wired.getNamesRemote()
- for k, v in pairs(cons) do
- local pipe = peripheral.wrap(v)
- if pipe then
- local id = pipe.getAvailableItems()[1][1]
- pipe.makeRequest(id, amount)
- end
- end
- sleep(1250)
- end
- function checkEnergy(threshold)
- local leftPercent = leftCell.getEnergyStored("left") / leftCell.getMaxEnergyStored("left")
- local rightPercent = rightCell.getEnergyStored("right") / rightCell.getMaxEnergyStored("right")
- if leftPercent < threshold or rightPercent < threshold then
- request(1)
- end
- end
- while true do
- checkEnergy(0.95)
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement