Advertisement
sinkir

lua turtle my autoenchant

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