Advertisement
Telmelt777

Bucheron

Jul 23rd, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.14 KB | None | 0 0
  1. -- Slot16: vitre
  2. -- Slot15: terre
  3. -- Slot14: planche
  4. -- Slot13: coffre
  5. -- Slot12: sappling
  6. -- Slot11: 1 bois
  7. -- Slot1: bois
  8.  
  9.  
  10. function repositionnement(lieu)
  11.  if lieu == 3 then
  12.   local coffre = false
  13.   turtle.select(13)
  14.   while coffre == false do
  15.    turtle.turnRight()
  16.    if turtle.compare() == true then
  17.     coffre = true
  18.    end
  19.   end
  20.   turtle.turnLeft()
  21.   turtle.select(16)
  22.   while turtle.compareDown() == true do
  23.    turtle.forward()
  24.   end
  25.  elseif lieu == 1 then
  26.   turtle.select(16)
  27.   turtle.forward()
  28.   if turtle.detect() == false then
  29.    turtle.turnRight()
  30.    turtle.turnRight()
  31.    turtle.forward()
  32.    turtle.turnRight()
  33.    while turtle.compareDown() == true do
  34.     turtle.forward()
  35.    end
  36.   elseif turtle.compareDown() == true then
  37.    while turtle.compareDown() == true do
  38.     turtle.forward()
  39.    end
  40.   end
  41.   turtle.select(14)
  42.   if turtle.compareDown() == true then
  43.    turtle.turnRight()
  44.    turtle.turnRight()
  45.    turtle.select(16)
  46.    turtle.forward()
  47.    while turtle.compareDown() == true do
  48.     turtle.forward()
  49.    end
  50.   end
  51.  else
  52.   turtle.select(16)
  53.   turtle.forward()
  54.   turtle.turnLeft()
  55.   while turtle.compareDown() == false do
  56.    turtle.forward()
  57.    turtle.turnLeft()
  58.    turtle.forward()
  59.   end
  60.   turtle.turnLeft()
  61.   turtle.forward()
  62.  end
  63.  turtle.turnRight()
  64.  turtle.turnRight()
  65.  turtle.forward()
  66.  turtle.turnRight()
  67.  turtle.turnRight()
  68. end
  69.  
  70. function reperage()
  71.  local lieu = 0
  72.  turtle.select(16)
  73.  if turtle.detectDown() == false then
  74.   while turtle.detectUp() == true do
  75.    turtle.digUp()
  76.    turtle.up()
  77.   end
  78.   while turtle.down() == true do
  79.    sleep(0)
  80.   end
  81.  end
  82.  if turtle.compareDown() == false then
  83.   turtle.select(15)
  84.   if turtle.compareDown() == false then
  85.    turtle.select(14)
  86.    if turtle.compareDown() == false then
  87.     print("Erreur position!!!")
  88.     turtle.shutdown()
  89.    else
  90.     lieu = 3
  91.    end
  92.   else
  93.    turtle.select(15)
  94.    turtle.forward()
  95.    if turtle.compareDown() == true then
  96.     turtle.up()
  97.     turtle.up()
  98.     turtle.up()
  99.     turtle.up()
  100.    end
  101.    turtle.turnRight()
  102.    turtle.turnRight()
  103.    turtle.forward()
  104.    turtle.forward()
  105.    lieu = 2
  106.   end
  107.  else
  108.   lieu = 1
  109.  end
  110.  repositionnement(lieu)
  111. end
  112.  
  113. function checkFuel()
  114.  if turtle.getFuelLevel() < 10 then
  115.   turtle.select(1)
  116.   turtle.refuel()
  117.  end
  118.  if turtle.getFuelLevel() > 10 then
  119.   sleep(0)
  120.  else
  121.   print("Manque de combustible!!!")
  122.   turtle.shutdown()
  123.  end
  124. end
  125.  
  126. function echange()
  127.  if turtle.getItemCount(12) == 0 then
  128.   turtle.turnRight()
  129.   turtle.select(12)
  130.   turtle.suck()
  131.   turtle.turnLeft()
  132.  end
  133.  if turtle.getItemCount(2) > 0 then
  134.   turtle.turnLeft()
  135.   turtle.select(2)
  136.   turtle.drop()
  137.   turtle.turnRight()
  138.  end
  139. end
  140.  
  141. function mouv()
  142.  turtle.turnRight()
  143.  turtle.turnRight()
  144.  turtle.select(16)
  145.  turtle.forward()
  146.  while turtle.compareDown() == true do
  147.   turtle.forward()
  148.  end
  149.  turtle.turnRight()
  150.  turtle.turnRight()
  151.  turtle.forward()
  152.  echange()
  153.  while turtle.compareDown() == true do
  154.   turtle.forward()
  155.  end
  156.  turtle.turnRight()
  157.  turtle.turnRight()
  158.  turtle.forward()
  159.  turtle.turnRight()
  160.  turtle.turnRight()
  161. end
  162.  
  163. function coupe()
  164.  turtle.select(12)
  165.  turtle.place()
  166.  turtle.select(11)
  167.  while turtle.compare() == false do
  168.   sleep(15)
  169.  end
  170.  turtle.select(1)
  171.  turtle.dig()
  172.  turtle.forward()
  173.  turtle.select(11)
  174.  while turtle.compareUp() == true do
  175.   turtle.select(1)
  176.   turtle.digUp()
  177.   turtle.up()
  178.   checkFuel()
  179.  end
  180.  while turtle.down() == true do
  181.   sleep(0)
  182.  end
  183.  mouv()
  184. end
  185.  
  186. function fonctionnement()
  187.  checkFuel()
  188.  while true do
  189.   coupe()
  190.  end
  191. end
  192.  
  193.  
  194. reperage()
  195. fonctionnement()-- Slot16: vitre
  196. -- Slot15: terre
  197. -- Slot14: planche
  198. -- Slot13: coffre
  199. -- Slot12: sappling
  200. -- Slot11: 1 bois
  201. -- Slot1: bois
  202.  
  203.  
  204. function repositionnement(lieu)
  205.  if lieu == 3 then
  206.   local coffre = false
  207.   turtle.select(13)
  208.   while coffre == false do
  209.    turtle.turnRight()
  210.    if turtle.compare() == true then
  211.     coffre = true
  212.    end
  213.   end
  214.   turtle.turnLeft()
  215.   turtle.select(16)
  216.   while turtle.compareDown() == true do
  217.    turtle.forward()
  218.   end
  219.  elseif lieu == 1 then
  220.   turtle.select(16)
  221.   turtle.forward()
  222.   if turtle.detect() == false then
  223.    turtle.turnRight()
  224.    turtle.turnRight()
  225.    turtle.forward()
  226.    turtle.turnRight()
  227.    while turtle.compareDown() == true do
  228.     turtle.forward()
  229.    end
  230.   elseif turtle.compareDown() == true then
  231.    while turtle.compareDown() == true do
  232.     turtle.forward()
  233.    end
  234.   end
  235.   turtle.select(14)
  236.   if turtle.compareDown() == true then
  237.    turtle.turnRight()
  238.    turtle.turnRight()
  239.    turtle.select(16)
  240.    turtle.forward()
  241.    while turtle.compareDown() == true do
  242.     turtle.forward()
  243.    end
  244.   end
  245.  else
  246.   turtle.select(16)
  247.   turtle.forward()
  248.   turtle.turnLeft()
  249.   while turtle.compareDown() == false do
  250.    turtle.forward()
  251.    turtle.turnLeft()
  252.    turtle.forward()
  253.   end
  254.   turtle.turnLeft()
  255.   turtle.forward()
  256.  end
  257.  turtle.turnRight()
  258.  turtle.turnRight()
  259.  turtle.forward()
  260.  turtle.turnRight()
  261.  turtle.turnRight()
  262. end
  263.  
  264. function reperage()
  265.  local lieu = 0
  266.  turtle.select(16)
  267.  if turtle.detectDown() == false then
  268.   while turtle.detectUp() == true do
  269.    turtle.digUp()
  270.    turtle.up()
  271.   end
  272.   while turtle.down() == true do
  273.    sleep(0)
  274.   end
  275.  end
  276.  if turtle.compareDown() == false then
  277.   turtle.select(15)
  278.   if turtle.compareDown() == false then
  279.    turtle.select(14)
  280.    if turtle.compareDown() == false then
  281.     print("Erreur position!!!")
  282.     turtle.shutdown()
  283.    else
  284.     lieu = 3
  285.    end
  286.   else
  287.    turtle.select(15)
  288.    turtle.forward()
  289.    if turtle.compareDown() == true then
  290.     turtle.up()
  291.     turtle.up()
  292.     turtle.up()
  293.     turtle.up()
  294.    end
  295.    turtle.turnRight()
  296.    turtle.turnRight()
  297.    turtle.forward()
  298.    turtle.forward()
  299.    lieu = 2
  300.   end
  301.  else
  302.   lieu = 1
  303.  end
  304.  repositionnement(lieu)
  305. end
  306.  
  307. function checkFuel()
  308.  if turtle.getFuelLevel() < 10 then
  309.   turtle.select(1)
  310.   turtle.refuel()
  311.  end
  312.  if turtle.getFuelLevel() > 10 then
  313.   sleep(0)
  314.  else
  315.   print("Manque de combustible!!!")
  316.   turtle.shutdown()
  317.  end
  318. end
  319.  
  320. function echange()
  321.  if turtle.getItemCount(12) == 0 then
  322.   turtle.turnRight()
  323.   turtle.select(12)
  324.   turtle.suck()
  325.   turtle.turnLeft()
  326.  end
  327.  if turtle.getItemCount(2) > 0 then
  328.   turtle.turnLeft()
  329.   turtle.select(2)
  330.   turtle.drop()
  331.   turtle.turnRight()
  332.  end
  333. end
  334.  
  335. function mouv()
  336.  turtle.turnRight()
  337.  turtle.turnRight()
  338.  turtle.select(16)
  339.  turtle.forward()
  340.  while turtle.compareDown() == true do
  341.   turtle.forward()
  342.  end
  343.  turtle.turnRight()
  344.  turtle.turnRight()
  345.  turtle.forward()
  346.  echange()
  347.  while turtle.compareDown() == true do
  348.   turtle.forward()
  349.  end
  350.  turtle.turnRight()
  351.  turtle.turnRight()
  352.  turtle.forward()
  353.  turtle.turnRight()
  354.  turtle.turnRight()
  355. end
  356.  
  357. function coupe()
  358.  turtle.select(12)
  359.  turtle.place()
  360.  turtle.select(11)
  361.  while turtle.compare() == false do
  362.   sleep(15)
  363.  end
  364.  turtle.select(1)
  365.  turtle.dig()
  366.  turtle.forward()
  367.  turtle.select(11)
  368.  while turtle.compareUp() == true do
  369.   turtle.select(1)
  370.   turtle.digUp()
  371.   turtle.up()
  372.   checkFuel()
  373.  end
  374.  while turtle.down() == true do
  375.   sleep(0)
  376.  end
  377.  mouv()
  378. end
  379.  
  380. function fonctionnement()
  381.  checkFuel()
  382.  while true do
  383.   coupe()
  384.  end
  385. end
  386.  
  387.  
  388. reperage()
  389. fonctionnement()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement