Guest User

enchant

a guest
Mar 16th, 2013
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. m=peripheral.wrap("right")
  2. m.setAutoCollect(true)
  3.  
  4. function levelCheck()
  5.  level = m.getLevels()
  6.  shell.run("clear")
  7.  print ("Currently level: "..level)
  8.  return level
  9. end
  10.  
  11. function getBook()
  12.  local bookCount
  13.  local toReturn
  14.  turtle.suckUp()
  15.  bookCount = turtle.getItemCount(1)
  16.  if bookCount == 0 then
  17.   while bookCount == 0 do
  18.    shell.run("clear")
  19.    print ("Please Reload the Chest")
  20.    sleep(1)
  21.    turtle.suckUp()
  22.    bookCount = turtle.getItemCount(1)
  23.   end
  24.  end
  25.  if bookCount ~= 0 then do
  26.   print("Returning Books")
  27.   sleep(2)
  28.   returnBooks(bookCount)
  29.   print("Extra books returned")
  30.  end
  31.  end
  32. end
  33.  
  34. function returnBooks(x)
  35.  x = x-1
  36.  print("Returning "..x.." books")
  37.  sleep(4)
  38.  turtle.transferTo(2, x)
  39.  turtle.select(2)
  40.  turtle.dropUp()
  41.  turtle.select(1)
  42. end
  43.  
  44.  
  45.  
  46. while true do
  47.  local lv = levelCheck()
  48.  
  49.  if lv >= 30 then
  50.   getBook()
  51.   m.enchant(30)
  52.   turtle.drop()
  53.  end
  54.  sleep (2)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment