Q009

ComputerCraft turtle program - Enchanting

Aug 11th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local xpApi = peripheral.wrap("right")
  2. local collectedXp
  3.  
  4. while 1 do
  5.     if redstone.getInput("top") == true then
  6.         collectedXp = xpApi.collect()
  7.         if collectedXp > 0 then
  8.             print("Collected " .. collectedXp .. " XP. Current level is " .. xpApi.getLevels())
  9.         end
  10.         if xpApi.getLevels() >= 30 then
  11.             for i = 1, 15, 1 do
  12.                 if turtle.getItemCount(i) > 0 then
  13.                     turtle.select(i)
  14.                     break
  15.                 elseif i == 15 then
  16.                     print("out of books!")
  17.                 end
  18.             end
  19.             turtle.transferTo(16, 1)
  20.             turtle.select(16)
  21.             xpApi.enchant(30)
  22.             turtle.drop()
  23.             print("Book enchanted..")
  24.         end
  25.         sleep(5)
  26.     else
  27.         sleep(10)
  28.     end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment