Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAXSTEPS=50
- -- Digs forward, one up and one down
- function dig()
- while turtle.detect() do
- turtle.dig()
- sleep(1)
- end
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- end
- -- Returns a table {found: true, slot: 7} or {found: false}
- -- itemName is expected to be what turtle.getItemDetail returns
- -- for instance minecraft:torch
- function find(itemName)
- report = {["found"] = false}
- for slot=1,16 do
- item = turtle.getItemDetail(slot)
- if (item ~= nil and item.name == itemName) then
- report["found"] = true
- report["slot"] = slot
- return report
- end
- end
- return report
- end
- -- Try to place a torch if it can
- function placeTorch()
- torch = find("minecraft:torch")
- if (torch.found) then
- turtle.select(torch.slot)
- turtle.turnLeft()
- turtle.dig()
- turtle.place()
- turtle.turnRight()
- end
- end
- for steps=1,MAXSTEPS do
- dig()
- if (steps%6 == 0) then
- placeTorch()
- end
- end
- turtle.turnRight()
- dig()
- turtle.turnRight()
- for steps=1,MAXSTEPS do
- dig() -- no need to place torches
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement