SHOW:
|
|
- or go back to the newest paste.
| 1 | local length = 61 | |
| 2 | local width = 61 | |
| 3 | ||
| 4 | local function refuel() | |
| 5 | if turtle.getFuelLevel() < 50 then | |
| 6 | local prev = turtle.getSelectedSlot() | |
| 7 | turtle.select(1) | |
| 8 | if not turtle.refuel(4) then | |
| 9 | print('Need more fuel')
| |
| 10 | while not turtle.refuel(4) do | |
| 11 | sleep(3) | |
| 12 | end | |
| 13 | end | |
| 14 | turtle.select(prev) | |
| 15 | end | |
| 16 | end | |
| 17 | ||
| 18 | - | local function tryForwards() |
| 18 | + | local function tryBackwards() |
| 19 | refuel() | |
| 20 | - | while not turtle.forward() do |
| 20 | + | turtle.back() |
| 21 | - | if turtle.detect() then |
| 21 | + | |
| 22 | - | turtle.dig() |
| 22 | + | |
| 23 | - | sleep(.5) |
| 23 | + | |
| 24 | - | while turtle.detect() do |
| 24 | + | |
| 25 | - | turtle.dig() |
| 25 | + | |
| 26 | - | sleep(.5) |
| 26 | + | |
| 27 | while empty do | |
| 28 | - | elseif turtle.attack() then |
| 28 | + | |
| 29 | - | else |
| 29 | + | |
| 30 | - | sleep(1) |
| 30 | + | |
| 31 | empty = false | |
| 32 | turtle.select(n) | |
| 33 | return | |
| 34 | end | |
| 35 | end | |
| 36 | sleep(3) | |
| 37 | end | |
| 38 | else | |
| 39 | turtle.select(turtle.getSelectedSlot() + 1) | |
| 40 | end | |
| 41 | end | |
| 42 | ||
| 43 | local function placeBlock() | |
| 44 | for i = 0, 2, 1 do | |
| 45 | if not turtle.place() or turtle.getItemCount() == 0 then | |
| 46 | while turtle.getItemCount() == 0 do | |
| 47 | advance() | |
| 48 | end | |
| 49 | end | |
| 50 | end | |
| 51 | end | |
| 52 | ||
| 53 | local function turnAround(i) | |
| 54 | if i%2 == 1 then | |
| 55 | turtle.turnRight() | |
| 56 | - | if not turtle.detectDown() then |
| 56 | + | tryBackwards() |
| 57 | - | if not turtle.placeDown() or turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= "minecraft:stone_slab" then |
| 57 | + | |
| 58 | - | while turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= "minecraft:stone_slab" do |
| 58 | + | |
| 59 | - | advance() |
| 59 | + | |
| 60 | turtle.turnLeft() | |
| 61 | tryBackwards() | |
| 62 | placeBlock() | |
| 63 | turtle.turnLeft() | |
| 64 | end | |
| 65 | - | turtle.placeDown() |
| 65 | + | |
| 66 | turtle.select(2) | |
| 67 | for i = 1, length, 1 do | |
| 68 | - | tryForwards() |
| 68 | + | |
| 69 | refuel() | |
| 70 | tryBackwards() | |
| 71 | placeBlock() | |
| 72 | - | turtle.forward() |
| 72 | + | |
| 73 | turnAround(i) | |
| 74 | end |