Advertisement
Guest User

mine

a guest
Aug 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. local realDepth = 0
  2. local rightTurn = true --If turning right will face the turtle in the right direction
  3. local oneHigh = false
  4.  
  5. local xDistance = 0
  6. local yDistance = 0
  7. local zDistance = 0
  8.  
  9.  
  10. function initialColumn(depth) --Dig the initial column. Digs down either until it reaches depth, or it can't go down
  11.     for i = 1,depth do
  12.         turtle.digDown()
  13.         if turtle.down() then
  14.             realDepth = i
  15.             zDistance = zDistance + 1
  16.         else --If it cant go down, it adjusts what realDepth is (How deep the turtle can go)
  17.             print("Hit the end! i:")
  18.             print(i)
  19.                     realDepth = i - 1
  20.             break
  21.         end
  22.     end
  23.     for i = 1,realDepth do --Return to surface
  24.         turtle.up()
  25.         zDistance = zDistance - 1
  26.     end
  27. end
  28.  
  29. function turnaround()
  30.     turtle.turnLeft()
  31.     turtle.turnLeft()
  32. end
  33.  
  34. function empty() --Empties inventory starting at slot 16
  35.     turnaround()
  36.     for i = 16,1,-1 do
  37.         turtle.select(i)
  38.         turtle.drop()
  39.     end
  40.  turnaround()
  41. end
  42.  
  43. function digSlab(twoHigh, size)
  44.     for x = 1,size do --Dimensions of the slab
  45.         for y = 1,size do  
  46.            
  47.             if (y == size) and not (x == size) then --When we hit the end
  48.                 if rightTurn then
  49.                     turtle.turnRight()
  50.                 else
  51.                     turtle.turnLeft()
  52.                 end
  53.                 digBlock()
  54.                 turtle.forward()
  55.                 if rightTurn then
  56.                     turtle.turnRight()
  57.                 else
  58.                     turtle.turnLeft()
  59.                 end
  60.                 rightTurn = not rightTurn --Change which direction to turn next time. This way the turtle will snake around
  61.             else
  62.                 digBlock()
  63.                 turtle.forward() --Goes forward  
  64.                 if twoHigh then --If we have to dig two high, also dig upwards
  65.                     digUp()
  66.                 end            
  67.             end
  68.         end
  69.         if x == size then
  70.             print("Done slab! Now figure out returning to origin")
  71.             --Returning to origin
  72.             if not rightTurn then --Face the correct direction
  73.                 turtle.turnRight()
  74.             else
  75.                 turtle.turnLeft()
  76.             end
  77.            
  78.             --March on back
  79.             for x = 1, size do
  80.                 turtle.forward()
  81.             end
  82.            
  83.             if not rightTurn then --Face back towards the front
  84.                 turtle.turnRight()
  85.             else
  86.                 turtle.turnLeft()
  87.             end
  88.            
  89.         end
  90.     end
  91. end
  92.  
  93. function digBlock()
  94.     local success,data = turtle.inspect()
  95.     if (data.name == "minecraft:sand") or (data.name == "minecraft:gravel") then --If theres sand or gravel in front of the turtle
  96.         while turtle.dig() do --Dig as long as you can
  97.         end
  98.     end
  99.     turtle.dig() --Try to dig, even if nothing can fall in front of it
  100. end
  101.  
  102. function digUp()
  103.     turtle.digUp() --Dig at first
  104.     local success,data = turtle.inspectUp()
  105.     if (data.name == "minecraft:sand") or (data.name == "minecraft:gravel") then --If theres sand or gravel above the turtle now
  106.         while turtle.digUp() do --Dig as long as you can
  107.         end
  108.     end
  109. end
  110.  
  111. initialColumn(4)
  112. empty()
  113. turtle.down()
  114. digSlab(not oneHigh, 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement