Advertisement
Guest User

mine

a guest
Dec 16th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.65 KB | None | 0 0
  1. local configue = {x,z,y}
  2.   configue.x = 10
  3.   configue.z = 10
  4.   configue.y = 0
  5. local z = 1
  6. local x = 1
  7. local y = 1
  8. local w = 0
  9. local maxCarbu = 100000
  10. local woodFuel = 15
  11. local nivCarbu = turtle.getFuelLevel()
  12.  
  13. local function tourneDroite()
  14.     turtle.turnRight()
  15.       if w == 0 then
  16.           w = 1  write(" droite ")
  17.         elseif w == 1 then
  18.           w = 2  write(" deriere ")
  19.         elseif w == 2 then
  20.           w = 3  write(" gauche ")
  21.         elseif w == 3 then
  22.           w = 0  write(" devant ")
  23.       end
  24.      
  25.  end
  26.  
  27. local function tourneGauche()
  28.   turtle.turnLeft()
  29.     if w == 0 then
  30.         w = 3 write("gauche ")
  31.       elseif w == 3 then
  32.         w = 2 write("deriere ")
  33.       elseif w == 2 then
  34.         w = 1 write("droite ")
  35.       elseif w == 1 then
  36.         w = 0 write("devant ")
  37.     end
  38.  
  39.  end
  40.  
  41. local function carburant()
  42.   o = x+z+20
  43.     if o < nivCarbu then
  44.        
  45. end
  46.  
  47. local function dig()
  48.     turtle.digUp()
  49.     turtle.digDown()
  50.   end
  51.  
  52. local function deplaceMine()
  53.     turtle.dig()
  54.     turtle.forward()
  55.   end
  56.  
  57. local function deplaceZ()
  58.     while z > 1 do
  59.       turtle.forward()
  60.       z = z-1
  61.       write(" z:"..z)
  62.     end
  63.  end
  64.  
  65. local function deplaceX()
  66.     while x > 1 do
  67.       turtle.forward()
  68.       x = x-1
  69.       write(" w:"..x)
  70.     end
  71. end
  72.  
  73. local function mineZ()
  74. if configue.z > z then  
  75.   while configue.z > z do
  76.    if w == 0 then
  77.     dig()
  78.     deplaceMine()
  79.     dig()
  80.     z = z + 1  
  81.     write(" z:"..z)
  82.     elseif w == 1 then
  83.       tourneGauche()
  84.      end        
  85.    end
  86.   end
  87.   if w == 1 then
  88.     tourneDroite()
  89.   if w == 2 then
  90.     while z > 1 do
  91.       dig()
  92.       deplaceMine()
  93.       dig()
  94.       z = z-1
  95.       write(" z:"..z)
  96.       end
  97.      end
  98.    end
  99. end
  100. local function mineX()
  101.   if w == 0 then
  102.       tourneDroite()
  103.       deplaceMine()
  104.       x = x+1
  105.       write(" x:"..x)
  106.     elseif w == 2 then
  107.       tourneGauche()
  108.       deplaceMine()
  109.       x = x + 1
  110.       write(" x:"..x)
  111.     end
  112.  end
  113.    
  114. local function mineXZ()
  115.     while configue.x > x do
  116.       mineZ()
  117.       mineX()
  118.       if configue.x == x then
  119.         mineZ()
  120.       end
  121.     end
  122. end
  123.  
  124. local function retourZ()
  125.  while z > 1 do
  126.   if w == 2 then
  127.     deplaceZ()
  128.   elseif w == 0 then
  129.     tourneDroite()
  130.   elseif w == 1 then
  131.     tourneDroite()
  132.   elseif w == 3 then
  133.     tourneGauche()
  134.   end
  135.  end
  136. end
  137.  
  138. local function retourX()
  139.  while x > 1 do
  140.    if w == 3 then
  141.      deplaceX()
  142.    elseif w == 0 then
  143.      tourneGauche()
  144.    elseif w == 1 then
  145.      tourneDroite()
  146.    elseif w == 2 then
  147.      tourneDroite()
  148.     end
  149.   end
  150. end
  151. mineXZ()
  152. retourZ()
  153. retourX()
  154. turtle.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement