SHOW:
|
|
- or go back to the newest paste.
1 | local finished = false | |
2 | local wall = 0 | |
3 | local x = 0 | |
4 | local z = 0 | |
5 | local x1 = 0 | |
6 | local z1 = 0 | |
7 | ||
8 | function line() | |
9 | turtle.select(2) | |
10 | if not turtle.detectDown() then | |
11 | turtle.placeDown() | |
12 | print("block placed") | |
13 | end | |
14 | if not turtle.detect() then | |
15 | turtle.forward() | |
16 | print("moving forward") | |
17 | if wall == 0 then | |
18 | x = x + 1 | |
19 | else | |
20 | x = x - 1 | |
21 | end | |
22 | else | |
23 | turtle.select(3) | |
24 | if turtle.compare() then | |
25 | finished = true | |
26 | print("i am finished") | |
27 | else | |
28 | print("I have reached a wall") | |
29 | if wall == 0 then | |
30 | turtle.turnRight() | |
31 | turtle.forward() | |
32 | z = z + 1 | |
33 | turtle.turnLeft() | |
34 | while not turtle.detect() do | |
35 | turtle.forward() | |
36 | x = x + 1 | |
37 | end | |
38 | print("I have reached the second wall") | |
39 | turtle.select(3) | |
40 | if turtle.compare() then | |
41 | finished = true | |
42 | print("i am finished") | |
43 | end | |
44 | turtle.select(2) | |
45 | wall = 1 | |
46 | turtle.turnRight() | |
47 | turtle.turnRight() | |
48 | elseif wall == 1 then | |
49 | turtle.turnLeft() | |
50 | turtle.forward() | |
51 | z = z + 1 | |
52 | turtle.turnRight() | |
53 | while not turtle.detect() do | |
54 | turtle.forward() | |
55 | x = x - 1 | |
56 | end | |
57 | print("I have reached the third wall") | |
58 | turtle.select(3) | |
59 | if turtle.compare() then | |
60 | finished = true | |
61 | print("i am finished") | |
62 | end | |
63 | turtle.select(2) | |
64 | wall = 0 | |
65 | turtle.turnLeft() | |
66 | turtle.turnLeft() | |
67 | end | |
68 | end | |
69 | end | |
70 | end | |
71 | ||
72 | function base() | |
73 | if wall == 0 then | |
74 | turtle.turnLeft() | |
75 | else | |
76 | turtle.turnRight() | |
77 | end | |
78 | print(z1) | |
79 | print(x1) | |
80 | while z1 <= 1 do | |
81 | turtle.forward() | |
82 | z1 = z1 - 1 | |
83 | end | |
84 | turtle.turnLeft() | |
85 | while x1 <= 1 do | |
86 | turtle.forward() | |
87 | x1 = x1 - 1 | |
88 | end | |
89 | turtle.down() | |
90 | turtle.suck(2) | |
91 | if turtle.getItemCount(2) == 1 then | |
92 | print("Welp, no more items, ending.") | |
93 | turtle.turnLeft() | |
94 | turtle.turnLeft() | |
95 | finished = true | |
96 | end | |
97 | print("returning to work location") | |
98 | turtle.up() | |
99 | turtle.turnLeft() | |
100 | turtle.turnLeft() | |
101 | while x1 ~= x do | |
102 | turtle.forward() | |
103 | x1 = x1 + 1 | |
104 | end | |
105 | turtle.turnRight() | |
106 | while z1 ~= z do | |
107 | turtle.forward() | |
108 | z1 = z1 + 1 | |
109 | end | |
110 | turtle.down() | |
111 | if wall == 0 then | |
112 | turtle.turnLeft() | |
113 | else | |
114 | turtle.turnRight() | |
115 | end | |
116 | end | |
117 | ||
118 | while finished == false do | |
119 | - | -- if turtle.getItemCount(2) == 1 then |
119 | + | if turtle.getItemCount(2) == 1 then |
120 | - | -- print("I have run out of blocks") |
120 | + | print("I have run out of blocks") |
121 | -- os.pullevent("turtle_inventory") | |
122 | -- print("my inventory has changed, sure hope it was blocks") | |
123 | -- print("returning to base") | |
124 | -- turtle.up() | |
125 | -- z1 = z | |
126 | -- x1 = x | |
127 | -- base() | |
128 | - | -- end |
128 | + | turtle.select(4) |
129 | turtle.transferTo(2) | |
130 | turtle.select(5) | |
131 | turtle.transferTo(2) | |
132 | turtle.select(6) | |
133 | turtle.transferTo(2) | |
134 | turtle.select(7) | |
135 | turtle.transferTo(2) | |
136 | turtle.select(8) | |
137 | turtle.transferTo(2) | |
138 | turtle.select(9) | |
139 | turtle.transferTo(2) | |
140 | turtle.select(10) | |
141 | turtle.transferTo(2) | |
142 | turtle.select(11) | |
143 | turtle.transferTo(2) | |
144 | turtle.select(12) | |
145 | turtle.transferTo(2) | |
146 | turtle.select(13) | |
147 | turtle.transferTo(2) | |
148 | turtle.select(14) | |
149 | turtle.transferTo(2) | |
150 | turtle.select(15) | |
151 | turtle.transferTo(2) | |
152 | turtle.select(16) | |
153 | turtle.transferTo(2) | |
154 | turtle.select(2) | |
155 | end | |
156 | if turtle.getFuelLevel() < 1 then | |
157 | turtle.select(1) | |
158 | turtle.refuel(1) | |
159 | print("I have refueled") | |
160 | end | |
161 | line() | |
162 | print("restarting while loop") | |
163 | end |