Xonoa

chunkMine

Jan 18th, 2021 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. os.loadAPI("tMV.lua")
  2.  
  3. local sideLength = 16
  4. local atMaxDepth = false
  5. local nextDepth = 0
  6.  
  7. --mines and moves forward
  8. function mineForward()
  9. while turtle.dig() do
  10. os.sleep(0.1)
  11. end
  12. while not tMV.tForward() do
  13. os.sleep(0.1)
  14. end
  15. turtle.digDown()
  16. turtle.digUp()
  17. end
  18.  
  19. --mines an 8x8 layer, 3 high
  20. function mineLayer()
  21. for i=1,sideLength do
  22. mineForward()
  23. end
  24. tMV.tTurnRight()
  25. for i=(sideLength-1),1,-1 do
  26. for j=1,2 do
  27. for k=1,i do
  28. mineForward()
  29. end
  30. tMV.tTurnRight()
  31. end
  32. dumpCobble()
  33. end
  34. end
  35.  
  36. --mines to the next layer down. returns true if the turtle couldnt move any further down
  37. function layerDown(layerDepth)
  38. local atBedrock = false
  39.  
  40. tMV.face(1)
  41. for i=1,-1*layerDepth do
  42. turtle.digDown()
  43. if not tMV.tDown() then
  44. atBedrock = true
  45. end
  46. end
  47.  
  48. return atBedrock
  49. end
  50.  
  51. --return to home and dump ores
  52. function dropOffOres()
  53. tMV.goHome()
  54. tMV.face(3)
  55. for slot=2,16 do
  56. turtle.select(slot)
  57. turtle.drop()
  58. end
  59. end
  60.  
  61. --dumps all cobble on the ground
  62. function dumpCobble()
  63. for slot=2,16 do
  64. turtle.select(slot)
  65. if turtle.compareTo(1) then
  66. turtle.dropDown(64)
  67. end
  68. end
  69. end
  70.  
  71. --main loop. mines a layer, gets the depth it was at, goes home to drop off ores, then returns to that depth +3. if it hits bedrock the loop ends
  72. while not atMaxDepth do
  73. print(nextDepth)
  74. mineLayer()
  75. nextDepth = tMV.getPos()[2] - 3
  76. print(nextDepth)
  77. print("")
  78. dropOffOres()
  79.  
  80. if layerDown(nextDepth) then
  81. atMaxDepth = true
  82. end
  83. end
  84.  
  85. tMV.goHome()
  86.  
Add Comment
Please, Sign In to add comment