SHARE
    TWEET
    Xmann1

    miner.lua

    Apr 21st, 2025 (edited)
    504
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Lua 2.22 KB | None | 0 0
    1. local max_depth = 64
    2. local max_width = 64
    3. local fuel_estimate = max_depth * 2 + 2 * max_width
    4. function forward(dig)
    5. while not turtle.forward() do
    6. if dig then
    7. block, data = turtle.inspect()
    8. if block and data.name ~= "computercraft:turtle_normal" then
    9. turtle.dig()
    10. end
    11. else
    12. print("Waiting in queue......")
    13. end
    14. end
    15. end
    16. function up(dig)
    17. while not turtle.up() do
    18. if dig then
    19. turtle.digUp()
    20. else
    21. print("Waiting in queue......")
    22. end
    23. end
    24. end
    25. function down(dig)
    26. while not turtle.down() do
    27. if dig then
    28. turtle.digDown()
    29. else
    30. print("Waiting in queue......")
    31. end
    32. end
    33. end
    34. print("Waiting for fuel...")
    35. while true do
    36. turtle.suckDown(1)
    37. turtle.refuel(1)
    38. if turtle.getFuelLevel() >= fuel_estimate then
    39. print("We have enough fuel to go mining!")
    40. break
    41. end
    42. end
    43. local width = 0
    44. for i=1, max_width / 2 do
    45. forward(true)
    46. width = width + 1
    47. print("Looking for free mining spot at width=" .. width)
    48. if turtle.detectDown() then
    49. print("Free spot at width=" .. width .. "!")
    50. break
    51. end
    52. end
    53. turtle.digDown()
    54. up()
    55. local highspot = width % 2 == 1
    56. if highspot then
    57. print("Going up to high mining spot")
    58. for i=1, 3 do
    59. up(true)
    60. end
    61. end
    62. turtle.turnLeft()
    63. for depth=1, max_depth do
    64. forward(true)
    65. turtle.digUp()
    66. turtle.digDown()
    67. print("Mining out, depth=" .. depth)
    68. end
    69. print("Gone far enough out, mining back")
    70. if highspot then
    71. turtle.turnLeft()
    72. forward(true)
    73. width = width - 1
    74. turtle.turnLeft()
    75. else
    76. turtle.turnRight()
    77. forward(true)
    78. width = width + 1
    79. turtle.turnRight()
    80. end
    81. for i=1, max_depth do
    82. turtle.digUp()
    83. turtle.digDown()
    84. forward(true)
    85. print("Mining back, depth=" .. (max_depth - i))
    86. end
    87. turtle.digUp()
    88. turtle.digDown()
    89. print("Mining done, returning to station")
    90. turtle.turnRight()
    91. if highspot then
    92. print("Going down from high mining spot")
    93. for i=1, 3 do
    94. down()
    95. end
    96. end
    97. for i=1, width do
    98. forward()
    99. end
    100. for i=1, 16 do
    101. turtle.select(i)
    102. turtle.dropUp()
    103. end
    104. turtle.select(1)
    105. turtle.turnRight()
    106. turtle.turnRight()
    107. down()
    108. os.reboot()
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /