edoreld

recharger

Mar 25th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. m = peripheral.wrap("right")
  2. fullToDeliver = 3
  3. lastEmptySlot = 14
  4. fullBattery = 15
  5. emptyBattery = 16
  6.  
  7.  
  8. function clearScreen()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. end
  12.  
  13. function isCurrentSlotFullBattery()
  14. return turtle.compareTo(fullBattery)
  15. end
  16.  
  17. function isSlotEmptyBattery()
  18. return turtle.compareTo(emptyBattery)
  19. end
  20.  
  21. function isSlotHalfBattery(i)
  22. return not (isCurrentSlotFullBattery or isSlotEmptyBattery or isSlotEmpty(i))
  23. end
  24.  
  25. function isSlotEmpty(i)
  26. return turte.getItemCount(i) == 0
  27. end
  28.  
  29. turtle.select(1)
  30.  
  31. clearScreen()
  32.  
  33. while true do
  34. clearScreen()
  35. print("=========================")
  36.  
  37. turtle.select(1)
  38. -- Suck all the items in the ender chest
  39. while turtle.suckUp() do
  40. os.sleep(1)
  41. end
  42.  
  43. m.suckSneaky(1,1)
  44.  
  45. -- Go through all the sucked items in the inventory
  46. for i=1,lastEmptySlot do
  47. turtle.select(i)
  48.  
  49. if isCurrentSlotFullBattery() then
  50. print("Putting a full battery in the chest")
  51. turtle.dropUp()
  52. elseif isSlotEmptyBattery() or isSlotHalfBattery(i) then
  53. print("Putting an empty or not fully charged battery in the battery box")
  54. m.dropSneaky(1,1)
  55. end
  56. os.sleep(1)
  57. end
  58. os.sleep(5)
  59. end
Advertisement
Add Comment
Please, Sign In to add comment