Advertisement
Guest User

gridMine

a guest
Dec 21st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. local tArgs = {...}
  2. local tunnels
  3. local length
  4.  
  5. local tunnels = tonumber(tArgs[1])
  6. local length = tonumber(tArgs[2])
  7. local counter = 0
  8.  
  9. function gridMine()
  10.   for i = 0, tunnels - 1 do
  11.     for z = 0, length do
  12.       dig()
  13.       digUp()
  14.       if z ~= 0 and z % 6 == 0 then
  15.         turtle.up()
  16.         turtle.turnRight()
  17.         turtle.dig()
  18.         turtle.select(1)
  19.         turtle.place()
  20.         turtle.turnLeft()
  21.         turtle.down()
  22.       elseif z == length then
  23.         turtle.up()
  24.         turtle.dig()
  25.         turtle.select(1)
  26.         turtle.place()
  27.         turtle.down()
  28.       end
  29.     end
  30.     if (i % 2 == 0) then
  31.       turtle.turnRight()
  32.     else
  33.       checkInventory()
  34.       turtle.turnLeft()
  35.     end
  36.     if i == 1 then
  37.       for x = 0, 2 do
  38.         dig()
  39.         digUp()
  40.       end
  41.     end  
  42.       turtle.turnLeft()
  43.       turtle.turnLeft()
  44.       for x = 0, 2 do
  45.         dig()
  46.         digUp()
  47.       end
  48.     for z = 0, 6 do
  49.       dig()
  50.       digUp()
  51.     end
  52.     turtle.turnRight()
  53.     turtle.turnRight()
  54.     for z = 0, 2 do
  55.       turtle.forward()
  56.     end
  57.     if (i % 2 == 0) then
  58.       turtle.turnRight()
  59.     else
  60.       turtle.turnLeft()
  61.     end
  62.   end
  63.   turtle.turnLeft()
  64.   while not turtle.detect() do
  65.     turtle.forward()
  66.   end
  67. end
  68.  
  69. function dig()
  70.   while not turtle.forward() do
  71.     turtle.dig()
  72.     sleep(.25)
  73.   end
  74. end
  75.  
  76. function digUp()
  77.   turtle.digUp()
  78.   sleep(.25)
  79. end
  80.  
  81.  
  82. function checkInventory()
  83.   turtle.select(16)
  84.   if turtle.getItemCount() > 0 then
  85.     turtle.turnLeft()
  86.     while not turtle.detect() do
  87.       turtle.forward()
  88.       counter = counter + 1
  89.     end
  90.     for i = 2, 16 do
  91.       turtle.select(i)
  92.       turtle.drop()
  93.     end
  94.     turtle.turnLeft()
  95.     turtle.turnLeft()
  96.     for i = 0, counter - 1 do
  97.       turtle.forward()
  98.     end
  99.     turtle.turnLeft()
  100.   end
  101. end
  102.  
  103. gridMine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement