What you will end up with
A Turtle that digs a straight tunnel of any length, collects everything it mines, and returns to the starting position with a full inventory. From here you can expand to branch mining, staircase mining, or quarry patterns.
What you need
- A Mining Turtle (crafted from a Turtle + a pickaxe)
- Fuel in its inventory — coal, lava buckets, or any burnable item
- Space underground or in a flat area for the Turtle to dig
turtle.getFuelLevel(). Refuel by placing fuel items in slot 1
and running turtle.refuel() from the terminal.
Turtle movement basics
Turtles move one block at a time. All movement functions return
true on success or false, "reason" on failure (e.g. blocked).
turtle.forward()/turtle.back()— move forward or backturtle.up()/turtle.down()— move up or downturtle.turnLeft()/turtle.turnRight()— rotate 90°turtle.dig()— mine the block in frontturtle.digUp()/turtle.digDown()— mine above or belowturtle.detect()— returns true if there is a block in front
Step 1 — Fuel up the Turtle
- Right-click the Mining Turtle to open its inventory.
- Place coal (or any fuel) in slot 1.
- Open the terminal (click the screen icon or right-click while sneaking) and run:
turtle.refuel() print(turtle.getFuelLevel())You should see a number above 0.
Step 2 — Simple straight tunnel
Place the Turtle facing into a wall. Create a new program:
Type the following:
Save, exit, and run:
while turtle.detect() loop handles falling blocks like gravel and sand —
it keeps digging until the path is clear before moving forward.
Step 3 — Return to start
After mining, the Turtle needs to come back. Extend mine.lua with a return
function after the mining loop:
Step 4 — Check the inventory
After returning, inspect what was collected with this snippet in the terminal:
Full mine.lua — complete script
Useful Turtle API methods
turtle.getFuelLevel()— current fuel amountturtle.refuel(count)— consume items from selected slot as fuelturtle.getItemCount(slot)— number of items in a slotturtle.getItemDetail(slot)— item name and count for a slotturtle.drop(count)— drop items from selected slot in frontturtle.select(slot)— set the active inventory slot (1–16)
Troubleshooting
- Turtle does not move — check fuel level. Run
turtle.refuel()with coal in slot 1. - Inventory full, items lost — add a check inside the loop: if
turtle.getItemCount(16) > 0(last slot has items), return early to empty the inventory. - Turtle stuck in lava/water — add
turtle.place()with a bucket or useturtle.inspect()to detect liquid before moving.