Advertisement
PancakePhD

Battery Crafter

Feb 4th, 2023 (edited)
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. chestFull = false
  2.  
  3. function fillSlot(slot)
  4.     turtle.select(slot)
  5.     while turtle.getItemCount() < 16 do
  6.         turtle.suck(16-turtle.getItemCount())
  7.     end
  8. end
  9.  
  10. function emptyInventory()
  11.     for i=1,16 do
  12.         turtle.select(i)
  13.         item = turtle.getItemDetail()
  14.         if item and item.name == "ic2:itembatre" then
  15.             dropped, message = turtle.drop()
  16.  
  17.             if not dropped then
  18.                 chestFull = true
  19.                 return
  20.             else
  21.                 chestFull = false
  22.             end
  23.         end
  24.     end
  25. end
  26.  
  27. function craftBattery()
  28.     turtle.turnRight()
  29.     turtle.turnRight()
  30.    
  31.     turtle.select(2)
  32.     while turtle.getItemCount() < 16 do
  33.         turtle.suckUp(16-turtle.getItemCount())
  34.     end
  35.  
  36.     fillSlot(5)
  37.     fillSlot(7)
  38.     fillSlot(9)
  39.     fillSlot(11)
  40.  
  41.     turtle.turnRight()
  42.  
  43.     fillSlot(6)
  44.     fillSlot(10)
  45.  
  46.     turtle.craft()
  47.  
  48.     turtle.turnRight()
  49.  
  50.     emptyInventory()
  51. end
  52.  
  53. while true do
  54.     while not chestFull do
  55.         emptyInventory()
  56.         if not chestFull then
  57.             craftBattery()
  58.         end
  59.     end
  60.     sleep(1)
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement