Advertisement
Ubidibity

DigTarget.lua

May 4th, 2025 (edited)
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | Gaming | 0 0
  1. local function forward()
  2.   while not turtle.forward() do
  3.     turtle.dig()
  4.   end
  5. end
  6.  
  7. target="minecraft:dirt"
  8. target2="minecraft:grass_block"
  9. lw=8 -- length and width, It'll just be a box
  10.  
  11.  
  12. local function digUp()
  13.   local has_block, data = turtle.inspectUp()
  14.   if has_block then
  15.     if data.name == target or data.name == target2 then
  16.       turtle.digUp()
  17.     else
  18.       print("Target=",data.name)
  19.     end
  20.   end
  21. end
  22.  
  23. function digDown()
  24.   local has_block, data = turtle.inspectDown()
  25.   if has_block then
  26.     if data.name == target or data.name == target2 then
  27.       turtle.digDown()
  28.     else
  29.       print("Target=",data.name)
  30.     end
  31.   end
  32. end
  33.  
  34. flip=0
  35. depth=3
  36.  
  37. function flipper(f)
  38.   if f==0 then
  39.     turtle.turnRight()
  40.     forward()
  41.     turtle.turnRight()
  42.     f=1
  43.   else
  44.     turtle.turnLeft()
  45.     f=0
  46.     forward()
  47.     turtle.turnLeft()
  48.   end
  49.   return f
  50. end
  51.  
  52. for z=1,depth do
  53.   for x=1,lw do
  54.     for y=1,lw do
  55.       digUp()
  56.       digDown()
  57.       forward()
  58.     end
  59.     flip=flipper(flip)
  60.     forward()
  61.   end
  62.  
  63.   -- flip=flipper(flip)
  64.   if flip==0 then
  65.     flip=1
  66.   else
  67.     flip=0
  68.   end
  69.   for x=1,3 do
  70.     turtle.digDown()
  71.     turtle.down()
  72.   end
  73. end
  74. for x=1,(3*depth) do
  75.   while not turtle.up() do
  76.     turtle.digUp()
  77.   end
  78. end
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement