SHOW:
|
|
- or go back to the newest paste.
1 | function goForward(nTimes, bBreak, bRetry) | |
2 | local nTimes = nTimes or 1 | |
3 | local bBreak = bBreak or false | |
4 | local bRetry = bRetry or true | |
5 | - | turtle.turnRight() |
5 | + | for i = 1,nTimes do |
6 | - | turtle.turnRight() |
6 | + | if (bRetry) then |
7 | - | turtle.forward() |
7 | + | while not turtle.forward() do |
8 | - | turtle.forward() |
8 | + | if (bBreak) then |
9 | - | turtle.turnLeft() |
9 | + | turtle.dig() |
10 | - | turtle.forward() |
10 | + | print("Digging") |
11 | - | turtle.forward() |
11 | + | end |
12 | - | turtle.forward() |
12 | + | print("Retrying forward movement") |
13 | - | turtle.turnLeft() |
13 | + | end |
14 | else | |
15 | if (not turtle.forward() and bBreak) then | |
16 | turtle.dig() | |
17 | turtle.forward() | |
18 | end | |
19 | end | |
20 | end | |
21 | end | |
22 | ||
23 | function turnRight(nTimes) | |
24 | local nTimes = nTimes or 1 | |
25 | - | turtle.turnLeft() |
25 | + | for i = 1,nTimes do |
26 | - | turtle.forward() |
26 | + | turtle.turnRight() |
27 | - | turtle.forward() |
27 | + | end |
28 | - | turtle.forward() |
28 | + | |
29 | - | turtle.turnRight() |
29 | + | |
30 | - | turtle.forward() |
30 | + | function turnLeft(nTimes) |
31 | - | turtle.forward() |
31 | + | local nTimes = nTimes or 1 |
32 | for i = 1,nTimes do | |
33 | turtle.turnLeft() | |
34 | end | |
35 | end | |
36 | ||
37 | turtle.select(1) | |
38 | turtle.suckDown() | |
39 | ||
40 | turnRight(2) | |
41 | goForward(2) | |
42 | turnLeft() | |
43 | goForward(3) | |
44 | turnLeft() | |
45 | ||
46 | for i=1,turtle.getItemCount(1) do | |
47 | turtle.select(1) | |
48 | turtle.place() | |
49 | sleep(2) | |
50 | ||
51 | turtle.select(2) | |
52 | turtle.dig() | |
53 | sleep(2) | |
54 | end | |
55 | ||
56 | turnLeft() | |
57 | goForward(3) | |
58 | turnRight() | |
59 | goForward(2) | |
60 | ||
61 | turtle.select(2) | |
62 | turtle.dropDown() |