Advertisement
Ubidibity

clayminer.lua

Apr 24th, 2025 (edited)
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.90 KB | Gaming | 0 0
  1. -- variation on box miner but instead of bobbing up and down like a sewing needle this is the more classic run straight through
  2. -- also as I'm doing this for clay I'll set it to only dig up or down if there is clay present.
  3.  
  4. depth=3 -- small makes testing retrieval easier if I get flip logic wrong
  5. width=8
  6. length=8
  7. flip=0
  8.  
  9. local function pauseMe()
  10.   print("Press any key...")
  11.   os.pullEvent("key")
  12. end
  13.  
  14. local function goUp()
  15.   while not turtle.up() do
  16.     turtle.digUp()
  17.   end
  18. end
  19.  
  20. local function mineClayUp()
  21.       local has_block, data = turtle.inspectUp()
  22.       if has_block then
  23.         if data.name == "minecraft:clay" then
  24.           turtle.digUp()
  25.         end
  26.       end
  27. end
  28.  
  29. local function mineClayDown()
  30.       local has_block, data = turtle.inspectDown()
  31.       if has_block then
  32.         if data.name == "minecraft:clay" then
  33.           turtle.digDown()
  34.         end
  35.       end
  36. end
  37.  
  38. local function goForward()
  39.     while not turtle.forward() do
  40.       mineClayDown()
  41.       mineClayUp()
  42.       turtle.dig()
  43.       mineClayUp()
  44.       mineClayDown()
  45.     end
  46. end
  47.  
  48. local function goDown()
  49.   turtle.digDown()
  50.   turtle.down()
  51. end
  52.  
  53. turtle.digDown()
  54. turtle.down()
  55. turtle.digDown()
  56. turtle.down()
  57.  
  58. for z=1,depth do
  59.  
  60.   for x=1,length do
  61.  
  62.     for z=1,width do
  63.       goForward()
  64.     end  -- at width
  65.     if flip==0 then
  66.       flip=1
  67.       turtle.turnRight()
  68.       goForward()
  69.       turtle.turnRight()
  70.     else
  71.       turtle.turnLeft()
  72.       goForward()
  73.       turtle.turnLeft()
  74.       flip=0
  75.     end
  76.   end -- at length
  77.  
  78.   goDown()
  79.   goDown()
  80.  
  81.   if flip==0 then
  82.     turtle.turnLeft()
  83.   else
  84.     turtle.TurnRight()
  85.   end
  86. --  print("Debug: Check heading and depth.")
  87. --  pauseMe()
  88. end -- at depth
  89.  
  90. print("Return to surface (if applicable).")
  91. x=0
  92. while not turtle.up() or x<(depth+2) do -- up until you hit air or reach 'depth' height (relative 0)
  93.   goUp()
  94.   x=x+1
  95. end
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement