Advertisement
PancakePhD

Generator Crafter

Feb 4th, 2023 (edited)
631
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:blockgenerator" 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 craftGenerator()
  28.     turtle.select(2)
  29.     while turtle.getItemCount() < 16 do
  30.         turtle.suckUp(16-turtle.getItemCount())
  31.     end
  32.  
  33.     turtle.turnLeft()
  34.  
  35.     fillSlot(6)
  36.    
  37.     turtle.turnRight()
  38.     turtle.turnRight()
  39.  
  40.     fillSlot(10)
  41.  
  42.     turtle.craft()
  43.  
  44.     turtle.turnLeft()
  45.  
  46.     emptyInventory()
  47. end
  48.  
  49. while true do
  50.     while redstone.getInput("back") and not chestFull do
  51.         emptyInventory()
  52.         if not chestFull then
  53.             craftGenerator()
  54.         end
  55.     end
  56.     sleep(1)
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement