SHOW:
|
|
- or go back to the newest paste.
| 1 | local fl = turtle.getFuelLevel() | |
| 2 | if fl == 0 then | |
| 3 | turtle.select(1) | |
| 4 | turtle.refuel(4) | |
| 5 | end | |
| 6 | print("fuel:"..tostring(fl))
| |
| 7 | ||
| 8 | local function digline(b) | |
| 9 | local cut = 0 | |
| 10 | print("digline")
| |
| 11 | for i=1,b do | |
| 12 | if turtle.detect() then | |
| 13 | print("detect front")
| |
| 14 | local result = turtle.dig() | |
| 15 | if result then | |
| 16 | print("cut ok")
| |
| 17 | cut = cut + 1 | |
| 18 | else | |
| 19 | print("cannot cut")
| |
| 20 | break | |
| 21 | end | |
| 22 | end | |
| 23 | if turtle.detectUp() then | |
| 24 | local result = turtle.digUp() | |
| 25 | if result then | |
| 26 | cut = cut + 1 | |
| 27 | else | |
| 28 | break | |
| 29 | end | |
| 30 | end | |
| 31 | turtle.forward() | |
| 32 | end | |
| 33 | return cut | |
| 34 | end | |
| 35 | ||
| 36 | local h = 0 | |
| 37 | while true do | |
| 38 | local cut = 0 | |
| 39 | local ret = digline(1) | |
| 40 | cut = cut + ret | |
| 41 | turtle.turnLeft() | |
| 42 | ||
| 43 | ret = digline(1) | |
| 44 | cut = cut + ret | |
| 45 | turtle.turnLeft() | |
| 46 | ||
| 47 | ret = digline(1) | |
| 48 | cut = cut + ret | |
| 49 | turtle.turnLeft() | |
| 50 | ||
| 51 | ret = digline(1) | |
| 52 | cut = cut + ret | |
| 53 | turtle.turnLeft() | |
| 54 | ||
| 55 | if cut == 0 then | |
| 56 | print("no block at this height")
| |
| 57 | break | |
| 58 | end | |
| 59 | turtle.up() | |
| 60 | h = h + 1 | |
| 61 | end | |
| 62 | ||
| 63 | if h > 0 then | |
| 64 | for i=1,h do | |
| 65 | turtle.down() | |
| 66 | end | |
| 67 | end | |
| 68 |