SHOW:
|
|
- or go back to the newest paste.
1 | - | dbug=true |
1 | + | dbug=true |
2 | - | |
2 | + | |
3 | - | local function roadLength(rs) |
3 | + | local function roadLength(rs) |
4 | - | if dbug then |
4 | + | if dbug then |
5 | - | print("roadLength") |
5 | + | print("roadLength") |
6 | - | end |
6 | + | end |
7 | - | items=0 |
7 | + | items=0 |
8 | - | for i=1,15 do |
8 | + | for i=1,15 do |
9 | - | print(i) |
9 | + | print(i) |
10 | - | print(rs) |
10 | + | print(rs) |
11 | - | turtle.select(i) |
11 | + | turtle.select(i) |
12 | - | if turtle.compareTo(rs) then |
12 | + | if turtle.compareTo(rs) then |
13 | - | items=turtle.getItemCount(i)+items |
13 | + | items=turtle.getItemCount(i)+items |
14 | - | end |
14 | + | end |
15 | - | end |
15 | + | end |
16 | - | print(items) |
16 | + | print(items) |
17 | - | return items/2 |
17 | + | return items/2 |
18 | - | end |
18 | + | end |
19 | - | |
19 | + | |
20 | - | local function moveForward() |
20 | + | local function moveForward() |
21 | - | if dbug then |
21 | + | if dbug then |
22 | - | print("moveForward") |
22 | + | print("moveForward") |
23 | - | end |
23 | + | end |
24 | - | while not turtle.forward() do |
24 | + | while not turtle.forward() do |
25 | - | turtle.attack() |
25 | + | turtle.attack() |
26 | - | end |
26 | + | end |
27 | - | end |
27 | + | end |
28 | - | |
28 | + | |
29 | - | local function getItem() |
29 | + | local function getItem() |
30 | - | if dbug then |
30 | + | if dbug then |
31 | - | print("getItem") |
31 | + | print("getItem") |
32 | - | end |
32 | + | end |
33 | - | while currentSlot ~= referenceSlot do |
33 | + | while currentSlot ~= referenceSlot do |
34 | - | turtle.select(currentSlot) |
34 | + | turtle.select(currentSlot) |
35 | - | while turtle.compareTo(referenceSlot) do |
35 | + | while turtle.compareTo(referenceSlot) do |
36 | - | return true |
36 | + | return true |
37 | - | end |
37 | + | end |
38 | - | currentSlot=currentSlot+1 |
38 | + | currentSlot=currentSlot+1 |
39 | - | end |
39 | + | end |
40 | - | quit=true |
40 | + | quit=true |
41 | - | return false |
41 | + | return false |
42 | - | end |
42 | + | end |
43 | - | |
43 | + | |
44 | - | local function dig() |
44 | + | local function dig() |
45 | - | if dbug then |
45 | + | if dbug then |
46 | - | print("dig") |
46 | + | print("dig") |
47 | - | end |
47 | + | end |
48 | - | turtle.dig() |
48 | + | turtle.dig() |
49 | - | turtle.digUp() |
49 | + | turtle.digUp() |
50 | - | turtle.digDown() |
50 | + | turtle.digDown() |
51 | - | turtle.up() |
51 | + | turtle.up() |
52 | - | turtle.digUp() |
52 | + | turtle.digUp() |
53 | - | turtle.down() |
53 | + | turtle.down() |
54 | - | end |
54 | + | end |
55 | - | |
55 | + | |
56 | - | local function clearArea() |
56 | + | local function clearArea() |
57 | - | if dbug then |
57 | + | if dbug then |
58 | - | print("clearArea") |
58 | + | print("clearArea") |
59 | - | end |
59 | + | end |
60 | - | dig() |
60 | + | dig() |
61 | - | if getItem() then |
61 | + | if getItem() then |
62 | - | turtle.placeDown() |
62 | + | turtle.placeDown() |
63 | - | turtle.turnLeft() |
63 | + | turtle.turnLeft() |
64 | - | turtle.dig() |
64 | + | turtle.dig() |
65 | - | moveForward() |
65 | + | moveForward() |
66 | - | turtle.turnRight() |
66 | + | turtle.turnRight() |
67 | - | dig() |
67 | + | dig() |
68 | - | end |
68 | + | end |
69 | - | if getItem() then |
69 | + | if getItem() then |
70 | - | turtle.placeDown() |
70 | + | turtle.placeDown() |
71 | - | turtle.turnRight() |
71 | + | turtle.turnRight() |
72 | - | moveForward() |
72 | + | moveForward() |
73 | - | turtle.turnLeft() |
73 | + | turtle.turnLeft() |
74 | - | end |
74 | + | end |
75 | - | end |
75 | + | end |
76 | - | |
76 | + | |
77 | - | --Start |
77 | + | --Start |
78 | - | xPos,zPos=0,0 |
78 | + | xPos,zPos=0,0 |
79 | - | xDir,zDir=0,1 |
79 | + | xDir,zDir=0,1 |
80 | - | height=0 |
80 | + | height=0 |
81 | - | referenceSlot=16 |
81 | + | referenceSlot=16 |
82 | - | currentSlot=1 |
82 | + | currentSlot=1 |
83 | - | quit=false |
83 | + | quit=false |
84 | - | |
84 | + | |
85 | - | zMax=roadLength(referenceSlot) |
85 | + | zMax=roadLength(referenceSlot) |
86 | - | |
86 | + | |
87 | - | if dbug then |
87 | + | if dbug then |
88 | - | print(xPos .. "," .. zPos) |
88 | + | print(xPos .. "," .. zPos) |
89 | - | print(xDir .. "," .. zDir) |
89 | + | print(xDir .. "," .. zDir) |
90 | - | print(height) |
90 | + | print(height) |
91 | - | print(zMax) |
91 | + | print(zMax) |
92 | - | end |
92 | + | end |
93 | - | |
93 | + | |
94 | - | print("Starting...") |
94 | + | print("Starting...") |
95 | - | turtle.dig() |
95 | + | turtle.dig() |
96 | - | while zPos < zMax and not quit do |
96 | + | while zPos < zMax and not quit do |
97 | - | moveForward() |
97 | + | moveForward() |
98 | - | zPos=zPos+1 |
98 | + | zPos=zPos+1 |
99 | - | print("zPos: " .. zPos) |
99 | + | print("zPos: " .. zPos) |
100 | - | clearArea() |
100 | + | clearArea() |
101 | - | end |
101 | + | end |
102 | - | |
102 | + | |
103 | print("zPos: " .. zPos) |