Advertisement
sinkir

lua turtle my autoenchant drop up

Oct 17th, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- pastebin get 5NNztFvW startup
  2. --   _____
  3. --  |  ___|   _ _ __   ___
  4. --  | |_ | | | | '_ \ / __|
  5. --  |  _|| |_| | | | | (__
  6. --  |_|   \__,_|_| |_|\___|
  7. --
  8.  
  9. left = function()
  10.     return turtle.turnLeft()
  11. end
  12.  
  13. right = function()
  14.     return turtle.turnRight()
  15. end
  16.  
  17. fuel = function()
  18.     return turtle.getFuelLevel()
  19. end
  20.  
  21. select = function(id)
  22.     return turtle.select(id)
  23. end
  24.  
  25. count = function(id)
  26.     return turtle.getItemCount(id)
  27. end
  28.  
  29. move = function(id, nb)
  30.     return turtle.transferTo(id, nb)
  31. end
  32.  
  33. --   _____
  34. --  |  ___|   _ _ __   ___
  35. --  | |_ | | | | '_ \ / __|
  36. --  |  _|| |_| | | | | (__
  37. --  |_|   \__,_|_| |_|\___|
  38. --
  39.  
  40. function init()
  41.     if(count(16) == 0)then
  42.         print("Pas de livre dans le slot 16")
  43.         --return false
  44.     end
  45.  
  46.     return true
  47. end
  48. function clear_inventory()
  49.     for i = 1,15 do
  50.         if(count(i)>0)then
  51.             turtle.select(i)
  52.             turtle.dropDown()
  53.         end
  54.     end
  55.     select(1)
  56. end
  57.  
  58. --  __  __       _        ____
  59. -- |  \/  | __ _(_)_ __  / /\ \
  60. -- | |\/| |/ _` | | '_ \| |  | |
  61. -- | |  | | (_| | | | | | |  | |
  62. -- |_|  |_|\__,_|_|_| |_| |  | |
  63. --                       \_\/_/
  64.  
  65.  
  66. args = { ... }
  67. if( args[1]==null)then
  68.     args[1] = 16
  69.     --print("Début de 'tree', par defaut, "..args[1].." blocks")
  70. else
  71.     --print("Début de 'tree', "..args[1].." blocks")
  72. end
  73.  
  74. stop=false
  75. if(init()==false) then
  76.     stop=true
  77. end
  78. xp=peripheral.wrap("right")
  79. xp.setAutoCollect(true)
  80. xplevel = xp.getLevels()
  81. while(stop==false)do
  82.     turtle.attack()
  83.     repeat
  84.         turtle.suck()
  85.     until turtle.suck() == false
  86.     turtle.attack()
  87.     if(count(16) > 0)then
  88.         if(xplevel ~= xp.getLevels())then
  89.             xplevel = xp.getLevels()
  90.             print("Level "..xplevel)
  91.             if(xplevel > 29) then
  92.                 clear_inventory()
  93.                 select(16)
  94.                 move(1,1)
  95.                 select(1)
  96.                 xp.enchant(30,30)
  97.                 --turtle.dropDown()
  98.                 turtle.dropUp()
  99.             end
  100.         end
  101.     end
  102.     turtle.attack()
  103.     repeat
  104.         turtle.suck()
  105.     until turtle.suck() == false
  106.     turtle.attack()
  107.     sleep(1)
  108.     if(count(2) > 0)then
  109.         clear_inventory()
  110.     end
  111.  
  112. end
  113.  
  114.  
  115. print('End')
  116. if(fuel() == 0) then
  117.   print('Ya plus de coco mon coco !')
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement