Advertisement
MrFoxit

Tree cutter v1

Sep 9th, 2021 (edited)
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.25 KB | None | 0 0
  1. turtle.select(16)
  2. local step = 0
  3. local selectedSlot = 0
  4. local errorPosStart = 0
  5. local time = 0
  6.  
  7. while true do
  8.    
  9.     if turtle.getFuelLevel() < 1 then
  10.         selectedSlot = turtle.getSelectedSlot()
  11.         turtle.select(15)
  12.         turtle.refuel()
  13.         turtle.select(selectedSlot)
  14.     end
  15.  
  16.  
  17.     if step == 0 and turtle.compareDown() then  
  18.         print("Je suis sur le block start !")    
  19.  
  20.         while not turtle.compare() do
  21.             turtle.turnLeft()
  22.         end
  23.    
  24.         turtle.turnRight()
  25.         turtle.turnRight()
  26.         turtle.up()
  27.         turtle.forward()
  28.         turtle.forward()
  29.         step = 1    
  30.  
  31.     end
  32.    
  33.     if step == 0 and not turtle.compareDown() then
  34.         if errorPosStart < 5 then
  35.             print("Je ne suis pas sur le block start !")
  36.             errorPosStart = errorPosStart + 1
  37.         else
  38.             print("Trop complex pour moi je me shutdown")
  39.             step = 3
  40.         end
  41.     end
  42.  
  43.  
  44.  
  45.     if step == 1 then
  46.        
  47.         turtle.select(14)
  48.    
  49.         if turtle.compare() then
  50.             print("Il y a un sapling j'attend")
  51.             step = 2
  52.         else
  53.             print("Il y a pas de sapling, mais y a t'il un arbre ?")
  54.             turtle.select(13)
  55.             if turtle.compare() then
  56.                 print("Il y a un arbre ! j'attend")
  57.                 step = 2
  58.             else
  59.                 print("Il y a ni sapling, ni arbre, je plante !")
  60.                 turtle.select(14)
  61.                 turtle.place()
  62.             end                        
  63.         end
  64.     end
  65.  
  66.     if step == 2 then
  67.        
  68.         turtle.select(13)
  69.         sleep(time)
  70.         if turtle.compare() then
  71.             turtle.dig()
  72.             turtle.digUp()
  73.             turtle.up()
  74.             time = 0        
  75.         else
  76.             time = 5
  77.             sleep(time)
  78.             turtle.select(14)
  79.             if turtle.compare() then
  80.                 sleep(time)
  81.                 print("J'attend...")
  82.             else
  83.                 step = 3
  84.                 time = 0
  85.             end
  86.         end        
  87.     end
  88.    
  89.     if step == 3 then
  90.         print("J'ai fini de couper l'arbre")
  91.         while turtle.down() do
  92.             turtle.down()
  93.         end
  94.         turtle.turnLeft()
  95.         turtle.turnLeft()
  96.         turtle.forward()
  97.         turtle.suck()
  98.         turtle.suck()
  99.         turtle.suck()
  100.         turtle.suck()
  101.         turtle.suck()
  102.         turtle.forward()
  103.         turtle.turnLeft()
  104.         turtle.turnLeft()
  105.         sleep(5)
  106.         turtle.suck()
  107.         turtle.suck()
  108.         turtle.suck()
  109.         turtle.suck()
  110.         turtle.suck()
  111.         turtle.turnLeft()
  112.         sleep(1)
  113.        
  114.         turtle.select(13)
  115.         while turtle.getItemCount() > 1 do
  116.             turtle.drop(1)
  117.         end
  118.         turtle.turnLeft()
  119.         turtle.turnLeft()
  120.         turtle.select(14)
  121.         sleep(1)
  122.        
  123.         while turtle.getItemCount() > 2 do
  124.             turtle.drop(1)
  125.         end
  126.        
  127.         local i = 1
  128.        
  129.         while i <= 12 do
  130.             turtle.select(i)
  131.             turtle.drop()
  132.             i = i + 1
  133.         end
  134.        
  135.  
  136.         turtle.select(16)                
  137.         step = 0
  138.        
  139.     end
  140. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement