Advertisement
Guest User

bucheron

a guest
Aug 23rd, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.76 KB | None | 0 0
  1. --Bucheron
  2. shell.run('clear')
  3. print("Dirt dans le slot 1, sappling en 2, fuel en 3 et log en 4.")
  4. print("nombre de colonnes ?")
  5. local x = io.read()
  6. print("nombres de lignes ?")
  7. local y = io.read()
  8.  
  9. --Debut des iterations
  10. while true do
  11.  
  12.         -- Boucle de refuel
  13.         while turtle.getFuelLevel()<200 do
  14.                 turtle.select(3)
  15.                 turtle.refuel(1)
  16.         end
  17.        
  18.         --Boucles de deplacement
  19.         turtle.turnLeft()
  20.         turtle.turnLeft()
  21.         turtle.forward()
  22.         turtle.turnRight()
  23.         --Boucle lignes
  24.         for i = 0 , y do
  25.                 --Boucle colonnes
  26.                 for j = 0 , x do
  27.                         --Detection arbre pousse + coupe
  28.                         print("boucle arbre")
  29.                         turtle.select(4)
  30.                         if turtle.compare() then
  31.                         print("arbre detecte")
  32.                                 turtle.dig()
  33.                                 turtle.forward()
  34.                                 while turtle.detectUp() do
  35.                                         turtle.digUp()  
  36.                                         turtle.up()
  37.                                 end
  38.                                 while not turtle.detectDown() do
  39.                                         turtle.down()
  40.                                 end
  41.                        
  42.                                 turtle.select(1)
  43.                                 turtle.digDown()
  44.                                 turtle.placeDown()
  45.                                 turtle.back()
  46.                         end
  47.                        
  48.                         --Detection Sapling present et placement
  49.                         print("boucle sapling")
  50.                         turtle.select(2)
  51.                         if not turtle.compare() then
  52.                         print("pas de sapling")
  53.                                 turtle.forward()
  54.                                 --Detection dirt prε83₯A9sente et placement
  55.                                 turtle.select(1)
  56.                                 if not turtle.compare() then
  57.                                         turtle.digDown()
  58.                                         turtle.placeDown()
  59.                                 end
  60.                                 turtle.back()
  61.                                 turtle.select(2)
  62.                                 turtle.place()
  63.                         end
  64.                         if x ~= i then
  65.                           turtle.turnLeft()
  66.                           turtle.forward()
  67.                           turtle.forward()
  68.                           turtle.forward()
  69.                           turtle.forward()
  70.                           turtle.turnRight()
  71.                         end
  72.                 end
  73.         --Retour debut de la colonne
  74.         turtle.turnLeft()
  75.                 for j = 1 , x do
  76.                         turtle.back()
  77.                         turtle.back()
  78.                         turtle.back()
  79.                         turtle.back()
  80.                 end
  81.                 turtle.back()
  82.                 turtle.turnRight()
  83.                 turtle.forward()
  84.                 turtle.forward()
  85.                 turtle.forward()
  86.                 turtle.forward()
  87.                 turtle.turnLeft()
  88.                 turtle.forward()
  89.                 turtle.turnRight()        
  90.         end
  91.  
  92. --Fin de la boucle
  93. turtle.turnRight()
  94. turtle.forward()
  95. turtle.turnRight()
  96. for i = 0 , y do
  97.         turtle.forward()
  98.         turtle.forward()
  99.         turtle.forward()
  100.         turtle.forward()
  101. end
  102. turtle.turnLeft()
  103.  
  104. --retour en position initiale + vidage inventaire
  105. for k = 4 , 9 do
  106.         turtle.select(k)
  107.         turtle.drop()
  108. end
  109. turtle.select(4)
  110. turtle.suck(1)
  111. os.sleep(10)
  112.  
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement