More

Examples.

Small, complete programs built only from the functions in these docs. Paste one into the deck, press Run, and watch the Console.

Walk and come back.

Travel with td.goTo without digging, then return with td.goHome.

walk_and_back.lualua
-- Walk around obstacles to a spot 6 blocks south of home without digging, then come back.td.setHome()local h = td.pos()local ok, err = td.goTo(h.x, h.y, h.z + 6, { dig = false })if not ok then error("could not get there: " .. tostring(err)) endassert(td.goHome({ dig = false }), "goHome failed")print("Back home")

A lit strip mine.

td.mine.strip with a taller main tunnel, shorter branches and a torch every 8 blocks. Carry torches, and an ender chest if you have one, so it can unload on the spot.

lit_strip_mine.lualua
-- A 2 high strip mine with torches, dropping junk when the inventory fills.td.setHome()local ok, why = td.mine.strip{  length = 48,  spacing = 3,  branch = 6,  height = 2,  torches = 8,  dropJunk = true,}if ok then print("Strip mine done") else print("Stopped early: " .. why) end

A custom corridor job.

Your own loop inside td.run, calling check() before each block.

corridor.lualua
-- Custom job: dig a 1x2 corridor 20 blocks forward, placing a torch every 8 blocks.-- td.run returns home afterwards; check() keeps enough fuel and empties a full inventory.local LENGTH, TORCH_EVERY = 20, 8 td.setHome()td.run("Corridor", {}, function(check)  for i = 1, LENGTH do    check()    assert(td.digMove("forward"))    td.clear("up")    if i % TORCH_EVERY == 0 then      for slot = 1, 16 do        local d = turtle.getItemDetail(slot)        if d and d.name == "minecraft:torch" then          turtle.select(slot)          turtle.placeUp()          break        end      end    end  endend)

Fuel up, then dig a hole.

Burn fuel from the inventory with td.refuel, fall back to the shared fuel chest with td.refuelAtDepot, then run td.mine.hole.

fuel_then_hole.lualua
-- Make sure there is fuel, then dig a 4 by 4 hole 6 deep (the turtle sits on the near-left corner).local NEED = 600 local level = turtle.getFuelLevel()if level ~= "unlimited" and level < NEED then  if not td.refuel(NEED) then    local ok, why = td.refuelAtDepot(NEED)    if not ok then error("no fuel: " .. tostring(why)) end  endend local ok, why = td.mine.hole{ width = 4, length = 4, depth = 6 }print(ok and "Hole done" or ("Stopped early: " .. why))

A tiny hut.

A four layer blueprint for td.build. Materials it does not carry are fetched from the supply chest, or home if none is set.

tiny_hut.lualua
-- A 5 by 5 hut: plank floor, cobblestone walls with a door gap, plank roof.-- Stand one block before the front-left corner of the floor, facing along the rows.local hut = {  palette = {    ["P"] = "minecraft:oak_planks",    ["C"] = "minecraft:cobblestone",  },  layers = {    { "PPPPP", "PPPPP", "PPPPP", "PPPPP", "PPPPP" },    { "CC.CC", "C...C", "C...C", "C...C", "CCCCC" },    { "CC.CC", "C...C", "C...C", "C...C", "CCCCC" },    { "PPPPP", "PPPPP", "PPPPP", "PPPPP", "PPPPP" },  },} td.setHome()                    -- home stays outside the buildassert(td.digMove("forward"))   -- step onto the front-left cornerlocal ok, why = td.build(hut, { name = "Tiny hut" })print(ok and "Hut built" or ("Build stopped: " .. why))