Driftix

turtle lumberjack new utility

Jan 4th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.31 KB | None | 0 0
  1. slot = 1
  2. slot_bois = 1
  3. h= 0
  4. a = true
  5.  
  6. while true do
  7.  
  8. --Les trucs indispensables au début :D
  9. turtle.forward()
  10. turtle.select(1)
  11.  
  12. function recherche(param)         -- FONCTION FUEL2
  13.   while slot <16 do
  14.  
  15.     while turtle.getItemCount() == 0 do
  16.         if slot == 16 then
  17.           slot = 0
  18.         end
  19.         slot = slot +1
  20.         turtle.select(slot)
  21.     end
  22.  
  23.     local data = turtle.getItemDetail(slot)
  24.     if data.name == param then
  25.       turtle.select(slot)
  26.       return 0
  27.     end
  28.     slot = slot +1
  29.     turtle.select(slot)
  30.   end
  31. end
  32.  
  33. function fuel()                        -- FONCTION FUEL1
  34.   turtle.select(1)
  35.   recherche("minecraft:coal")
  36.   turtle.refuel(1)
  37.   print("[x] Refuel terminé !")
  38.   slot = 1
  39. end
  40.  
  41. function recolte()                      --RECOLTE
  42.   turtle.dig()
  43.   turtle.forward()
  44.   local success, bloc = turtle.inspectUp()
  45.   if bloc.name == "minecraft:log" then
  46.       while turtle.detectUp() == true do
  47.         turtle.digUp()
  48.         turtle.up()
  49.       end
  50.   end
  51.   while turtle.detectDown() == false do
  52.     recherche("minecraft:sapling")
  53.     turtle.down()
  54.   end
  55.   if turtle.detectDown() == true then
  56.     recherche("minecraft:sapling")
  57.     turtle.up()
  58.     turtle.placeDown()
  59.     turtle.forward()
  60.     turtle.digDown()
  61.     turtle.down()
  62.   end
  63. end
  64.  
  65. function esquive()                    --ESQUIVE
  66.   turtle.digUp()
  67.   turtle.up()
  68.   turtle.dig()
  69.   turtle.forward()
  70.   turtle.dig()
  71.   turtle.forward()
  72.   turtle.down()
  73. end
  74.  
  75. function creation()                               --CREATION
  76.   while turtle.detect() == true do  --A COMPLETER :D
  77.     turtle.up()
  78.   end
  79.   turtle.up()
  80.   if turtle.getItemCount(slot_bois) > 5 then
  81.       turtle.drop()
  82.   end
  83.   while turtle.detectDown() == false do
  84.     turtle.down()
  85.   end
  86. end
  87.  
  88. function tourne_droite()
  89.   turtle.turnRight()
  90.   turtle.forward()
  91.   turtle.turnRight()
  92. end
  93.  
  94. function tourne_gauche()
  95.   turtle.turnLeft()
  96.   turtle.forward()
  97.   turtle.turnLeft()
  98. end
  99.  
  100.  function drop()
  101.    recherche("minecraft:log")
  102.    turtle.drop()
  103.    turtle.turnRight()
  104. end
  105. --TRUC RIGOLOS
  106.  
  107.  
  108. if turtle.getFuelLevel() == 0 then    --Y'A ENCORE DU FUEL OU PAS ?
  109.   fuel()
  110. end
  111. if turtle.detect() == true then
  112.   local success, data = turtle.inspect()
  113.   if data.name == "minecraft:log" then   --Y'A DU BOIS ?
  114.     recolte()
  115.   end
  116.     local success, data = turtle.inspect()
  117.     if data.name =="minecraft:leaves" then
  118.       turtle.dig()
  119.       turtle.forward()
  120.     end
  121.  
  122.     local success, data = turtle.inspect()
  123.     if data.name == "minecraft:sapling" then                     -- Y'A UNE SAPLING ?
  124.       esquive()
  125.     end
  126.  
  127.     local success, data = turtle.inspect()
  128.     if data.name == "minecraft:furnace" then                      -- Y'A UN FURNACE ?
  129.       creation()
  130.     end
  131.  
  132.     local success, data = turtle.inspect()                        -- EST-CE QU'IL Y A UN MUR ?
  133.     if data.name == "minecraft:stone" then
  134.       tourne_droite()
  135.     end
  136.  
  137.     local success, data = turtle.inspect()                        -- EST-CE QU'IL Y A UN MUR ?
  138.     if data.name == "minecraft:planks" then
  139.       tourne_gauche()
  140.     end
  141.     local success, data = turtle.inspect()
  142.     if data.name == "minecraft:hopper" then
  143.       drop()
  144.     end
  145. end
  146. while turtle.detectDown() == false do
  147.   turtle.down()
  148. end
  149.  
  150. --Trucs a faire a la toute fin
  151. turtle.suck()
  152.  
  153. end
Advertisement
Add Comment
Please, Sign In to add comment