Driftix

Turtle lumberjack Computercraft (FINI)

Dec 26th, 2018
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 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. --TRUC RIGOLOS
  100.  
  101.  
  102. if turtle.getFuelLevel() == 0 then    --Y'A ENCORE DU FUEL OU PAS ?
  103.   fuel()
  104. end
  105. if turtle.detect() == true then
  106.   local success, data = turtle.inspect()
  107.   if data.name == "minecraft:log" then   --Y'A DU BOIS ?
  108.     recolte()
  109.   end
  110.     local success, data = turtle.inspect()
  111.     if data.name =="minecraft:leaves" then
  112.       turtle.dig()
  113.       turtle.forward()
  114.     end
  115.  
  116.     local success, data = turtle.inspect()
  117.     if data.name == "minecraft:sapling" then                     -- Y'A UNE SAPLING ?
  118.       esquive()
  119.     end
  120.  
  121.     local success, data = turtle.inspect()
  122.     if data.name == "minecraft:furnace" then                      -- Y'A UN FURNACE ?
  123.       creation()
  124.     end
  125.  
  126.     local success, data = turtle.inspect()                        -- EST-CE QU'IL Y A UN MUR ?
  127.     if data.name == "minecraft:stone" then
  128.       tourne_droite()
  129.     end
  130.  
  131.     local success, data = turtle.inspect()                        -- EST-CE QU'IL Y A UN MUR ?
  132.     if data.name == "minecraft:planks" then
  133.       tourne_gauche()
  134.     end
  135. end
  136. while turtle.detectDown() == false do
  137.   turtle.down()
  138. end
  139.  
  140. --Trucs a faire a la toute fin
  141. turtle.suck()
  142.  
  143. end
Add Comment
Please, Sign In to add comment