tbrixey

Basic Mining turtle 3x3 tunnel. Expecting length.

Jan 10th, 2021 (edited)
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local args = { ... }
  2.  
  3. local loopCount = 1
  4.  
  5. if #args ~= 1 then
  6.   print( "Requires length of tunnel" )
  7.   error()
  8. end
  9.  
  10. data = turtle.getItemDetail()
  11.  
  12. if not data then
  13.   print( "Requires torches in current slot" )
  14.   error()
  15. end
  16.  
  17. if data then
  18.   if data.name ~= "minecraft:torch" then
  19.     print( "Requires torches in current slot" )
  20.     error()
  21.   end
  22. end
  23.  
  24. print("Here we go!")
  25.  
  26. local deepTimes = tonumber(args[1])
  27.  
  28. local function checkIfDiamond()
  29.   success, data = turtle.inspect()
  30.   if success then
  31.     if data.name == "minecraft:diamond_ore" then
  32.       print( "Found diamond")
  33.       error()
  34.     end
  35.   end
  36.   success, data = turtle.inspectUp()
  37.   if success then
  38.     if data.name == "minecraft:diamond_ore" then
  39.       print( "Found diamond")
  40.       error()
  41.     end
  42.   end
  43.   success, data = turtle.inspectDown()
  44.   if success then
  45.     if data.name == "minecraft:diamond_ore" then
  46.       print( "Found diamond")
  47.       error()
  48.     end
  49.   end
  50. end
  51.  
  52. local function forwardLoop(loopAmount)
  53.   for i=1,loopAmount do
  54.     checkIfDiamond()
  55.     turtle.dig()
  56.     turtle.digUp()
  57.     turtle.digDown()
  58.     if (i % 10 == 0) and (loopCount == 2) then
  59.       turtle.placeDown()
  60.     end
  61.     turtle.forward()
  62.   end
  63.   loopCount = loopCount + 1
  64. end
  65.  
  66. local function turnLeft()
  67.   turtle.turnLeft()
  68.   turtle.dig()
  69.   turtle.digUp()
  70.   turtle.digDown()
  71.   turtle.forward()
  72.   turtle.turnLeft()
  73. end
  74.  
  75. local function turnRight()
  76.   turtle.turnRight()
  77.   turtle.dig()
  78.   turtle.digUp()
  79.   turtle.digDown()
  80.   turtle.forward()
  81.   turtle.turnRight()
  82. end
  83.  
  84. forwardLoop(deepTimes)
  85. turnLeft()
  86. forwardLoop(deepTimes)
  87. turnRight()
  88. forwardLoop(deepTimes)
  89.  
  90. print("Fin")
Add Comment
Please, Sign In to add comment