VADemon

Splashes stream exp turtle

Dec 3rd, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. exp = peripheral.wrap("right")
  2. exp.setAutoCollect(true)
  3. print("Enchanter & Grinder turtle is working!")
  4. chestDir = "dropDown" -- drop down into e.g. a chest
  5.  
  6. function drop_all_items()
  7.     for i = 1, 15 do
  8.         if turtle.getItemCount(i)~=0 then
  9.             turtle.select(i)
  10.             turtle[chestDir]()
  11.         end
  12.     end
  13.    
  14.     turtle.select(1)
  15. end
  16.  
  17. function enchantItem()
  18.     if turtle.getItemCount( 16 ) >= 1 then -- any items in the 16 slot?
  19.        
  20.         if turtle.getItemCount( 15 ) ~= 0 then
  21.             drop_all_items()
  22.         end
  23.        
  24.         turtle.select( 16 )  -- select 16th slot
  25.         turtle.transferTo(15, 1)
  26.         turtle.select(15)
  27.        
  28.         exp.enchant( 30 )  -- enchant that item with level 30
  29.         turtle[ chestDir ]() -- drop enchanted item
  30.        
  31.         turtle.select(1)  -- select the 1st slot again
  32.     else
  33.         print("Error: Books / items to enchant are missing from slot #16!")
  34.     end
  35. end
  36.  
  37. while true do -- always run the lines below
  38.     turtle.attack()
  39.    
  40.     if turtle.getItemCount( 1 ) > 0 then -- any items in the first slot?
  41.         drop_all_items() -- it will drop items to the chest below
  42.     end
  43.    
  44.     if exp.getLevels() >= 30 then -- internal EXP Level is 30 or above
  45.         enchantItem() -- execute the fuction above
  46.     end
  47.  
  48.     turtle.select(1)
  49.     sleep(.2) -- we are performance-friendly, the turtle waits a bit
  50. end -- end of loop
Add Comment
Please, Sign In to add comment