Advertisement
Guest User

mine

a guest
Aug 21st, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.25 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 twoHigh then --If we need to dig two high
  56.                     digUp()
  57.                 end
  58.                 if rightTurn then
  59.                     turtle.turnRight()
  60.                 else
  61.                     turtle.turnLeft()
  62.                 end
  63.                 rightTurn = not rightTurn --Change which direction to turn next time. This way the turtle will snake around
  64.             else
  65.                 digBlock()
  66.                 turtle.forward() --Goes forward  
  67.                 if twoHigh then --If we have to dig two high, also dig upwards
  68.                     digUp()
  69.                 end            
  70.             end
  71.         end
  72.         if x == size then
  73.             print("Done slab! Now figure out returning to origin")
  74.             --Returning to origin
  75.             if not rightTurn then --Face the correct direction
  76.                 turtle.turnRight()
  77.             else
  78.                 turtle.turnLeft()
  79.             end
  80.            
  81.             --March on back
  82.             for x = 1, size do
  83.                 turtle.forward()
  84.             end
  85.            
  86.             if not rightTurn then --Face back towards the front
  87.                 turtle.turnRight()
  88.             else
  89.                 turtle.turnLeft()
  90.             end
  91.            
  92.         end
  93.     end
  94. end
  95.  
  96. function digBlock()
  97.     local success,data = turtle.inspect()
  98.     if (data.name == "minecraft:sand") or (data.name == "minecraft:gravel") then --If theres sand or gravel in front of the turtle
  99.         while turtle.dig() do --Dig as long as you can
  100.         end
  101.     end
  102.     turtle.dig() --Try to dig, even if nothing can fall in front of it
  103. end
  104.  
  105. function digUp()
  106.     turtle.digUp() --Dig at first
  107.     local success,data = turtle.inspectUp()
  108.     if (data.name == "minecraft:sand") or (data.name == "minecraft:gravel") then --If theres sand or gravel above the turtle now
  109.         while turtle.digUp() do --Dig as long as you can
  110.         end
  111.     end
  112. end
  113.  
  114. initialColumn(4)
  115. empty()
  116. turtle.down()
  117. digSlab(not oneHigh, 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement