SHOW:
|
|
- or go back to the newest paste.
| 1 | - | function up() |
| 1 | + | |
| 2 | - | if turtle.detectUp() then |
| 2 | + | |
| 3 | - | |
| 3 | + | local function tryDigDown() |
| 4 | - | else |
| 4 | + | if turtle.digDown() then |
| 5 | - | turtle.up() |
| 5 | + | return true |
| 6 | - | up() |
| 6 | + | end |
| 7 | - | end |
| 7 | + | return false |
| 8 | end | |
| 9 | - | function mine() |
| 9 | + | |
| 10 | - | x=0 |
| 10 | + | local function tryDown() |
| 11 | - | while x < 1 do |
| 11 | + | if turtle.down() then |
| 12 | - | turtle.digDown() |
| 12 | + | print("Moving down")
|
| 13 | - | turtle.down() |
| 13 | + | return true |
| 14 | - | x = x+1 |
| 14 | + | else |
| 15 | - | end |
| 15 | + | if tryDigDown() then |
| 16 | print("Moving down")
| |
| 17 | - | function goUp() |
| 17 | + | turtle.down() |
| 18 | - | if turtle.digDown() == false then |
| 18 | + | return true |
| 19 | - | up() |
| 19 | + | end |
| 20 | - | end |
| 20 | + | end |
| 21 | print("Can't dig down")
| |
| 22 | - | function finish() |
| 22 | + | return false |
| 23 | - | x=0 |
| 23 | + | |
| 24 | - | while x < 70 do |
| 24 | + | |
| 25 | - | mine() |
| 25 | + | local function start() |
| 26 | - | goUp() |
| 26 | + | x = 0 |
| 27 | - | end |
| 27 | + | while tryDown() do |
| 28 | x = x + 1 | |
| 29 | print("Dug to level: "..x)
| |
| 30 | - | id, message, distance = rednet.receive() |
| 30 | + | end |
| 31 | - | function complete() |
| 31 | + | print("Cannot dig further. Bedrock likely reached")
|
| 32 | - | if message == "excavate" then |
| 32 | + | print("Returning to surface")
|
| 33 | - | finish() |
| 33 | + | while x > 0 do |
| 34 | - | end |
| 34 | + | if turtle.up() then |
| 35 | x = x - 1 | |
| 36 | else | |
| 37 | - | complete() |
| 37 | + | sleep(1) |
| 38 | end | |
| 39 | end | |
| 40 | print("Setting the next position")
| |
| 41 | turtle.forward() | |
| 42 | end | |
| 43 | ||
| 44 | local id, msg, dist = rednet.receive() | |
| 45 | if msg == "excavate" then | |
| 46 | start() | |
| 47 | end |