Advertisement
Telmelt777

Quarry

Jul 5th, 2014
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.56 KB | None | 0 0
  1. local taille = 64
  2. local check = false
  3. local x = 0
  4. local y = 0
  5. local z = 0
  6. local slot = 0
  7.  
  8. function checkpos()
  9.  turtle.select(16)
  10.  check = false
  11.  if turtle.compareDown() == true then
  12.   while check == false do
  13.    if turtle.compare() == true then
  14.     check = true
  15.     print("Demarrage en cours...")
  16.     return true
  17.    else
  18.     turtle.turnRight()
  19.    end
  20.   end
  21.  else
  22.   print("Erreur de placement!!!")
  23.   return false
  24.  end
  25. end
  26.  
  27. function checkreserve(niveau)
  28.  if niveau <= 5 then
  29.   turtle.refuel(1)
  30.  end
  31. end
  32.  
  33. function checkitem()
  34.  if turtle.getItemCount(15) >= 1 then
  35.   return false
  36.  else
  37.   return true
  38.  end
  39. end
  40.  
  41. function coffre()
  42.  slot = 1
  43.  while slot <= 15 do
  44.   turtle.select(slot)
  45.   if turtle.getItemCount(slot) > 0 then
  46.    if turtle.drop() == true then
  47.     turtle.drop()
  48.    else
  49.     print("Depot plein")
  50.     turtle.shutdown()
  51.    end
  52.   end
  53.   slot = slot + 1
  54.  end
  55.  turtle.select(1)
  56.  turtle.suckDown()
  57.  if turtle.getItemCount(1) >= 20 then
  58.   print("Depot effectue.")
  59.  else
  60.   print("Manque de combustible!!!")
  61.   turtle.shutdown()
  62.  end
  63. end
  64.  
  65. function positionnement()
  66.  turtle.turnRight()
  67.  turtle.turnRight()
  68.  turtle.dig()
  69.  turtle.forward()
  70. end
  71.  
  72. function retour(i, j, k)
  73.  while k > 0 do
  74.   turtle.up()
  75.   k = k - 1
  76.   checkreserve(turtle.getFuelLevel())
  77.  end
  78.  turtle.turnRight()
  79.  while i > 0 do
  80.   turtle.forward()
  81.   i = i - 1
  82.   checkreserve(turtle.getFuelLevel())
  83.  end
  84.  turtle.turnLeft()
  85.  while j >= 0 do
  86.   turtle.forward()
  87.   j = j - 1
  88.   checkreserve(turtle.getFuelLevel())
  89.  end
  90. end
  91.  
  92. function fonctionnement(i, j, k, x, y)
  93.  k = 0
  94.  while j > 0 do
  95.   turtle.dig()
  96.   turtle.forward()
  97.   j = j - 1
  98.   checkreserve(turtle.getFuelLevel())
  99.   if checkitem() == false then
  100.    retour(x, y, k)
  101.    return false
  102.   end
  103.  end
  104.  turtle.turnRight()
  105.  while i > 0 do
  106.   turtle.dig()
  107.   turtle.forward()
  108.   i = i - 1
  109.   checkreserve(turtle.getFuelLevel())
  110.   if checkitem() == false then
  111.    retour(x, y, k)
  112.    return false
  113.   end
  114.  end
  115.  turtle.turnRight()
  116.  turtle.digDown()
  117.  while turtle.down() == true do
  118.   turtle.digDown()
  119.   k = k + 1
  120.   checkreserve(turtle.getFuelLevel())
  121.   if checkitem() == false then
  122.    retour(x, y, k)
  123.    return false
  124.   end
  125.  end
  126.  retour(x, y, k)
  127.  return true
  128. end
  129.  
  130.  
  131. turtle.refuel(1)
  132. while x < taille do
  133.  while y < taille do
  134.   if checkpos() == true then
  135.    coffre()
  136.    positionnement()
  137.    if fonctionnement(x, y, z, x, y) == true then
  138.     y = y + 1
  139.    end
  140.   else
  141.    print("Arrêt imprevu de la quarry")
  142.    turtle.shutdown()
  143.   end
  144.  end
  145.  y = 0
  146.  x = x + 1
  147. end
  148. print("Fin normale du travail de la quarry")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement