DrFair

Book Enchanter

Apr 1st, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. xp = peripheral.wrap("left")
  2. xp.setAutoCollect(true)
  3. term.clear()
  4. elvl = 30
  5. turtle.select(1)
  6. n = 1
  7.  
  8. function swrite(str,x,y)
  9. term.setCursorPos(x,y)
  10. term.write(str)
  11. end
  12.  
  13. function swritecenter(str,y)
  14. term.setCursorPos(w/2 - #str/2,y)
  15. term.write(str)
  16. end
  17.  
  18. function cline(y)
  19. term.setCursorPos(1,y)
  20. term.clearLine()
  21. end
  22.  
  23. function getBook()
  24. first = true
  25. turtle.select(1)
  26. turtle.suckDown()
  27. while turtle.getItemCount(1) == 0 do
  28. if first then
  29. cline(2)
  30. swrite("Ran out of books.",1,2)
  31. first = false
  32. end
  33. os.sleep(3)
  34. turtle.suckDown()
  35. end
  36. if turtle.getItemCount(1) > 1 then
  37. turtle.transferTo(2,turtle.getItemCount(1)-1)
  38. turtle.select(2)
  39. turtle.dropDown()
  40. turtle.select(1)
  41. end
  42. end
  43.  
  44. while true do
  45. os.sleep(3)
  46. if xp.getLevels() >= 30 then
  47. getBook()
  48. xp.enchant(elvl)
  49. turtle.drop()
  50. cline(2)
  51. swrite("Enchanted book #"..n,1,2)
  52. n = n + 1
  53. end
  54. cline(1)
  55. swrite("Enchanting lvl 30 books. CLvl: "..xp.getLevels(),1,1)
  56. end
Advertisement
Add Comment
Please, Sign In to add comment