DiamondQ2

Fix up enchanting turtle

May 9th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. --Wraps the enchanting peripheral on the right side
  2. m = peripheral.wrap("right")
  3.  
  4. --Sets the automatic XP collection to true
  5. m.setAutoCollect(true)
  6.  
  7. --Sets some variables
  8. --Variable named level
  9. level = 0
  10. --Variable named books based of the number of items in slot
  11. books = turtle.getItemCount(1)
  12.  
  13. --Sets the variable level to the amount of levels the turtle has
  14. level = m.getLevels()
  15.  
  16. --The code to enchant a book if the variable level is higher as 30
  17. if level > 30 then
  18.   turtle.select(1)
  19.   print("level is higher as 30")
  20.   if (books > 1) then
  21.     turtle.transferTo(2, books - 1)
  22.   end
  23.   m.enchant(30)
  24.   turtle.drop()
  25.   if (books > 1) then
  26.     turtle.select(2)
  27.     turtle.transferTo(1, books - 1)
  28.   end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment