NiallDoherty

Enchant

Apr 10th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. e = peripheral.wrap("left")
  2. e.setAutoCollect(true)
  3. hasBooks = true
  4.  
  5. function unload()
  6.   turtle.turnRight()
  7.   for i = 2, 16 do
  8.     turtle.select(i)
  9.     turtle.drop()
  10.   end
  11.   turtle.select(1)
  12.   turtle.turnLeft()
  13. end
  14.  
  15. function checkFull()
  16.   if turtle.getItemCount(16) > 0 then
  17.     unload()
  18.   end
  19. end
  20.  
  21. function hasBook()
  22.   if turtle.getItemCount(1) == 1 and turtle.getItemDetail(1).name == "minecraft:book" then
  23.     return true
  24.   else
  25.     return false
  26.   end
  27. end
  28.  
  29. function depositBook()
  30.   turtle.turnLeft()
  31.   turtle.drop()
  32.   turtle.turnRight()
  33. end
  34.  
  35. function enchant()
  36.   if e.getLevels() >= 30 and hasBook() then
  37.     turtle.select(1)
  38.     e.enchant(30)
  39.     depositBook()
  40.     turtle.suckDown(1)
  41.   end
  42. end
  43.  
  44. while true do
  45.   enchant()
  46.   checkFull()
  47.   turtle.attack()
  48.   turtle.suck()
  49. end
Add Comment
Please, Sign In to add comment