richie3366

Turtle : arboretum sans humus

Dec 10th, 2012
9,313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. -- Ce programme [créé par richie3366] est libre de droit d'édition et d'utilisation abusive ;)
  2. -- Cependant, si jamais vous venez à faire une présentation de celui-ci, n'hésitez pas à mentionner
  3. -- son auteur ;)
  4. -- Twitter : https://twitter.com/richie3366
  5.  
  6. -- Susceptible d'être modifié à tout moment pour amélioration et/ou réparation.
  7. -- Dernière édition : 10/12/12
  8. -- Vidéo de présentation :
  9.  
  10. function detecteMarqueSol()
  11.     marque = -1
  12.     for i = 9, 12 do
  13.         turtle.select(i)
  14.        
  15.         if(turtle.compareDown()) then
  16.             marque = i
  17.         end
  18.     end
  19.    
  20.     return marque
  21. end
  22.  
  23.  
  24. -- Démarrage...
  25. i = 1
  26. turtle.select(16)
  27. while i <= 4 do
  28.     if turtle.compare() then
  29.         turtle.turnLeft()
  30.         i = 5
  31.     else
  32.         turtle.turnRight()
  33.         i = i + 1
  34.     end
  35. end
  36.  
  37. while true do
  38.  
  39.     marque = detecteMarqueSol()
  40.  
  41.     if(marque > 0) then
  42.         if marque == 12 then
  43.             if turtle.detect() then
  44.                 turtle.turnRight()
  45.             end
  46.         elseif marque == 11 then
  47.             turtle.turnLeft()
  48.             if not turtle.detect() then
  49.                 turtle.select(1)
  50.                 turtle.place()
  51.             end
  52.             turtle.turnRight()
  53.         elseif marque == 10 then
  54.             if turtle.getFuelLevel() < 96 then
  55.                 turtle.turnLeft()
  56.                 turtle.select(5)
  57.                 turtle.suck()
  58.                 if turtle.getItemCount(5) > 2 then
  59.                     turtle.drop(turtle.getItemCount(5) - 2)
  60.                 end
  61.                 turtle.refuel(1)
  62.                 turtle.turnRight()
  63.             end
  64.         elseif marque == 9 then
  65.             turtle.select(1)
  66.             if turtle.getItemCount(1) < 13 then
  67.                 turtle.turnLeft()
  68.                 turtle.suck()
  69.                
  70.                 if turtle.getItemCount(1) > 13 then
  71.                     turtle.drop(turtle.getItemCount(1) - 13)
  72.                 end
  73.                
  74.                 turtle.turnRight()
  75.             end
  76.         end
  77.     end
  78.  
  79.     turtle.forward()
  80.  
  81. end
Advertisement
Add Comment
Please, Sign In to add comment