|
1 |
| --- digtower |
2 | 1 | --
|
3 | 2 | -- This was created to dig/build a tower up in the nether including
|
4 | 3 | -- It will dig/build a 3by3 inside tower with full replacement of the
|
@@ -29,192 +28,193 @@ local junk_slot = 3
|
29 | 28 | local build_height = 8
|
30 | 29 |
|
31 | 30 | function refill(slot)
|
32 |
| - if turtle.getItemCount(slot) > 0 |
33 |
| - then |
34 |
| - for i=1,16 do |
35 |
| - turtle.select(i) |
36 |
| - if |
37 |
| - i ~= wall_slot and |
38 |
| - i ~= stair_slot and |
39 |
| - i ~= support_slot and |
40 |
| - turtle.compareTo(slot) |
41 |
| - then |
42 |
| - turtle.transferTo(slot) |
43 |
| - end |
44 |
| - end |
45 |
| - end |
| 31 | + if turtle.getItemCount(slot) > 0 |
| 32 | + then |
| 33 | + for i=1,16 do |
| 34 | + turtle.select(i) |
| 35 | + if |
| 36 | + i ~= wall_slot and |
| 37 | + i ~= stair_slot and |
| 38 | + i ~= support_slot and |
| 39 | + turtle.compareTo(slot) |
| 40 | + then |
| 41 | + turtle.transferTo(slot) |
| 42 | + end |
| 43 | + end |
| 44 | + end |
46 | 45 | end
|
47 | 46 |
|
48 | 47 | function resupply()
|
49 |
| - local need_wall = turtle.getItemCount(wall_slot) < 24 |
50 |
| - local need_stair = turtle.getItemCount(stair_slot) < build_height + 1 |
51 |
| - local need_support = turtle.getItemCount(support_slot) < 25 |
52 |
| - if need_wall and turtle.getItemCount(wall_slot) > 0 then |
53 |
| - print("Attempting refill of Wall") |
54 |
| - refill(wall_slot) |
55 |
| - end |
56 |
| - if need_stair and turtle.getItemCount(stair_slot) > 0 then |
57 |
| - print("Attempting refill of Stairs") |
58 |
| - refill(stair_slot) |
59 |
| - end |
60 |
| - if need_support and turtle.getItemCount(support_slot) > 0 then |
61 |
| - print("Attempting refill of Support") |
62 |
| - refill(support_slot) |
63 |
| - end |
| 48 | + local need_wall = turtle.getItemCount(wall_slot) < 24 |
| 49 | + local need_stair = turtle.getItemCount(stair_slot) < build_height + 1 |
| 50 | + local need_support = turtle.getItemCount(support_slot) < 25 |
| 51 | + if need_wall and turtle.getItemCount(wall_slot) > 0 then |
| 52 | + print("Attempting refill of Wall") |
| 53 | + refill(wall_slot) |
| 54 | + end |
| 55 | + if need_stair and turtle.getItemCount(stair_slot) > 0 then |
| 56 | + print("Attempting refill of Stairs") |
| 57 | + refill(stair_slot) |
| 58 | + end |
| 59 | + if need_support and turtle.getItemCount(support_slot) > 0 then |
| 60 | + print("Attempting refill of Support") |
| 61 | + refill(support_slot) |
| 62 | + end |
64 | 63 |
|
65 |
| - while |
66 |
| - (turtle.getItemCount(wall_slot) == 0 ) or |
67 |
| - (turtle.getItemCount(stair_slot) == 0 ) or |
68 |
| - (turtle.getItemCount(support_slot) == 0 ) |
69 |
| - do |
70 |
| - term.clear() |
71 |
| - term.setCursorPos(1,1) |
72 |
| - print("Turtle needs supplies") |
| 64 | + while |
| 65 | + (turtle.getItemCount(wall_slot) == 0 ) or |
| 66 | + (turtle.getItemCount(stair_slot) == 0 ) or |
| 67 | + (turtle.getItemCount(support_slot) == 0 ) |
| 68 | + do |
| 69 | + term.clear() |
| 70 | + term.setCursorPos(1,1) |
| 71 | + print("Turtle needs supplies") |
73 | 72 |
|
74 |
| - if need_wall then |
75 |
| - turtle.select(wall_slot) |
76 |
| - print("Wall Material in Slot "..wall_slot) |
77 |
| - end |
78 |
| - if need_stair then |
79 |
| - turtle.select(stair_slot) |
80 |
| - print("Stairs Material in Slot "..stair_slot) |
81 |
| - end |
82 |
| - if need_support then |
83 |
| - turtle.select(support_slot) |
84 |
| - print("Support Material in Slot "..support_slot) |
85 |
| - end |
86 |
| - sleep(5) |
| 73 | + if need_wall then |
| 74 | + turtle.select(wall_slot) |
| 75 | + print("Wall Material in Slot "..wall_slot) |
| 76 | + end |
| 77 | + if need_stair then |
| 78 | + turtle.select(stair_slot) |
| 79 | + print("Stairs Material in Slot "..stair_slot) |
| 80 | + end |
| 81 | + if need_support then |
| 82 | + turtle.select(support_slot) |
| 83 | + print("Support Material in Slot "..support_slot) |
| 84 | + end |
| 85 | + sleep(5) |
87 | 86 |
|
88 |
| - need_wall = turtle.getItemCount(wall_slot) < 24 |
89 |
| - need_stair = turtle.getItemCount(stair_slot) < build_height + 1 |
90 |
| - need_support = turtle.getItemCount(support_slot) < 25 |
91 |
| - if need_wall and turtle.getItemCount(wall_slot) > 0 then |
92 |
| - refill(wall_slot) |
93 |
| - end |
94 |
| - if need_stair and turtle.getItemCount(stair_slot) > 0 then |
95 |
| - refill(stair_slot) |
96 |
| - end |
97 |
| - if support_slot and turtle.getItemCount(support_slot) > 0 then |
98 |
| - refill(support_slot) |
99 |
| - end |
100 |
| - end |
| 87 | + need_wall = turtle.getItemCount(wall_slot) < 24 |
| 88 | + need_stair = turtle.getItemCount(stair_slot) < build_height + 1 |
| 89 | + need_support = turtle.getItemCount(support_slot) < 25 |
| 90 | + if need_wall and turtle.getItemCount(wall_slot) > 0 then |
| 91 | + refill(wall_slot) |
| 92 | + end |
| 93 | + if need_stair and turtle.getItemCount(stair_slot) > 0 then |
| 94 | + refill(stair_slot) |
| 95 | + end |
| 96 | + if support_slot and turtle.getItemCount(support_slot) > 0 then |
| 97 | + refill(support_slot) |
| 98 | + end |
| 99 | + end |
101 | 100 | end
|
102 | 101 |
|
103 | 102 | function doPlace(slot)
|
104 |
| - turtle.select(slot) |
105 |
| - return turtle.place(slot) |
| 103 | + turtle.select(slot) |
| 104 | + return turtle.place(slot) |
106 | 105 | end
|
107 | 106 |
|
108 | 107 | function doPlaceUp(slot)
|
109 |
| - turtle.select(slot) |
110 |
| - return turtle.placeUp(slot) |
| 108 | + turtle.select(slot) |
| 109 | + return turtle.placeUp(slot) |
111 | 110 | end
|
112 | 111 | function doPlaceDown(slot)
|
113 |
| - turtle.select(slot) |
114 |
| - return turtle.placeDown() |
| 112 | + turtle.select(slot) |
| 113 | + return turtle.placeDown() |
115 | 114 | end
|
116 | 115 | function safePlaceUp(slot)
|
117 |
| - turtle.select(slot) |
118 |
| - while not turtle.compareUp() and not turtle.placeUp(slot) do |
119 |
| - turtle.select(junk_slot) |
120 |
| - turtle.digUp() |
121 |
| - turtle.select(slot) |
122 |
| - end |
| 116 | + turtle.select(slot) |
| 117 | + while not turtle.compareUp() and not turtle.placeUp(slot) do |
| 118 | + turtle.select(junk_slot) |
| 119 | + turtle.digUp() |
| 120 | + turtle.select(slot) |
| 121 | + end |
123 | 122 | end
|
124 | 123 | function goForward()
|
125 |
| - while not turtle.forward() do |
126 |
| - turtle.select(junk_slot) |
127 |
| - turtle.dig() |
128 |
| - end |
| 124 | + while not turtle.forward() do |
| 125 | + turtle.select(junk_slot) |
| 126 | + turtle.dig() |
| 127 | + end |
129 | 128 | end
|
130 | 129 | function goForwardSafe()
|
131 |
| - safePlaceUp(support_slot) |
132 |
| - goForward() |
133 |
| - safePlaceUp(support_slot) |
| 130 | + safePlaceUp(support_slot) |
| 131 | + goForward() |
| 132 | + safePlaceUp(support_slot) |
134 | 133 | end
|
135 | 134 |
|
136 | 135 | function goUpSafe()
|
137 |
| - while not turtle.up() do |
138 |
| - turtle.select(junk_slot) |
139 |
| - turtle.digUp() |
140 |
| - end |
141 |
| - doPlaceUp(support_slot) |
142 |
| - for i=1,4 do |
143 |
| - doPlace(support_slot) |
144 |
| - turtle.turnLeft() |
145 |
| - end |
| 136 | + while not turtle.up() do |
| 137 | + turtle.select(junk_slot) |
| 138 | + turtle.digUp() |
| 139 | + end |
| 140 | + doPlaceUp(support_slot) |
| 141 | + for i=1,4 do |
| 142 | + doPlace(support_slot) |
| 143 | + turtle.turnLeft() |
| 144 | + end |
146 | 145 | end
|
147 | 146 |
|
148 | 147 | function doPlaceWall(slot)
|
149 |
| - turtle.select(slot) |
150 |
| - while not turtle.compare() and not turtle.place() do |
151 |
| - turtle.select(junk_slot) |
152 |
| - turtle.dig() |
153 |
| - turtle.select(slot) |
154 |
| - end |
| 148 | + turtle.select(slot) |
| 149 | + while not turtle.compare() and not turtle.place() do |
| 150 | + turtle.select(junk_slot) |
| 151 | + turtle.dig() |
| 152 | + turtle.select(slot) |
| 153 | + end |
155 | 154 | end
|
156 | 155 |
|
157 | 156 | function doPlaceCorner(slot)
|
158 |
| - turtle.turnRight() |
159 |
| - goForwardSafe() |
160 |
| - turtle.turnLeft() |
161 |
| - doPlaceWall(slot) |
162 |
| - turtle.turnRight() |
163 |
| - turtle.back() |
164 |
| - doPlaceWall(slot) |
165 |
| - turtle.turnLeft() |
166 |
| - doPlaceWall(slot) |
| 157 | + turtle.turnRight() |
| 158 | + goForwardSafe() |
| 159 | + turtle.turnLeft() |
| 160 | + doPlaceWall(slot) |
| 161 | + turtle.turnRight() |
| 162 | + turtle.back() |
| 163 | + doPlaceWall(slot) |
| 164 | + turtle.turnLeft() |
| 165 | + doPlaceWall(slot) |
167 | 166 | end
|
168 | 167 |
|
169 | 168 | function newFloor(floor_place)
|
170 |
| - goForwardSafe() |
171 |
| - doPlaceWall(wall_slot) |
172 |
| - turtle.turnLeft() |
173 |
| - if floor_place%8 == 0 then doPlaceDown(stair_slot) end |
174 |
| - goForwardSafe() |
175 |
| - doPlaceCorner(wall_slot) |
176 |
| - turtle.turnLeft() |
177 |
| - if floor_place%8 == 7 then doPlaceDown(stair_slot) end |
178 |
| - goForwardSafe() |
179 |
| - turtle.turnRight() |
180 |
| - doPlaceWall(wall_slot) |
181 |
| - turtle.turnLeft() |
182 |
| - if floor_place % 8 == 6 then doPlaceDown(stair_slot) end |
183 |
| - goForwardSafe() |
184 |
| - doPlaceCorner(wall_slot) |
185 |
| - turtle.turnLeft() |
186 |
| - if floor_place % 8 == 5 then doPlaceDown(stair_slot) end |
187 |
| - goForwardSafe() |
188 |
| - turtle.turnRight() |
189 |
| - doPlaceWall(wall_slot) |
190 |
| - turtle.turnLeft() |
191 |
| - if floor_place % 8 == 4 then doPlaceDown(stair_slot) end |
192 |
| - goForwardSafe() |
193 |
| - doPlaceCorner(wall_slot) |
194 |
| - turtle.turnLeft() |
195 |
| - if floor_place % 8 == 3 then doPlaceDown(stair_slot) end |
196 |
| - goForwardSafe() |
197 |
| - turtle.turnRight() |
198 |
| - doPlaceWall(wall_slot) |
199 |
| - turtle.turnLeft() |
200 |
| - if floor_place % 8 == 2 then doPlaceDown(stair_slot) end |
201 |
| - goForwardSafe() |
202 |
| - doPlaceCorner(wall_slot) |
203 |
| - turtle.turnLeft() |
204 |
| - if floor_place % 8 == 1 then doPlaceDown(stair_slot) end |
205 |
| - goForwardSafe() |
206 |
| - turtle.turnLeft() |
207 |
| - goForwardSafe() |
208 |
| - turtle.turnLeft() |
209 |
| - turtle.turnLeft() |
| 169 | + goForwardSafe() |
| 170 | + doPlaceWall(wall_slot) |
| 171 | + turtle.turnLeft() |
| 172 | + if floor_place%8 == 0 then doPlaceDown(stair_slot) end |
| 173 | + goForwardSafe() |
| 174 | + doPlaceCorner(wall_slot) |
| 175 | + turtle.turnLeft() |
| 176 | + if floor_place%8 == 7 then doPlaceDown(stair_slot) end |
| 177 | + goForwardSafe() |
| 178 | + turtle.turnRight() |
| 179 | + doPlaceWall(wall_slot) |
| 180 | + turtle.turnLeft() |
| 181 | + if floor_place % 8 == 6 then doPlaceDown(stair_slot) end |
| 182 | + goForwardSafe() |
| 183 | + doPlaceCorner(wall_slot) |
| 184 | + turtle.turnLeft() |
| 185 | + if floor_place % 8 == 5 then doPlaceDown(stair_slot) end |
| 186 | + goForwardSafe() |
| 187 | + turtle.turnRight() |
| 188 | + doPlaceWall(wall_slot) |
| 189 | + turtle.turnLeft() |
| 190 | + if floor_place % 8 == 4 then doPlaceDown(stair_slot) end |
| 191 | + goForwardSafe() |
| 192 | + doPlaceCorner(wall_slot) |
| 193 | + turtle.turnLeft() |
| 194 | + if floor_place % 8 == 3 then doPlaceDown(stair_slot) end |
| 195 | + goForwardSafe() |
| 196 | + turtle.turnRight() |
| 197 | + doPlaceWall(wall_slot) |
| 198 | + turtle.turnLeft() |
| 199 | + if floor_place % 8 == 2 then doPlaceDown(stair_slot) end |
| 200 | + goForwardSafe() |
| 201 | + doPlaceCorner(wall_slot) |
| 202 | + turtle.turnLeft() |
| 203 | + if floor_place % 8 == 1 then doPlaceDown(stair_slot) end |
| 204 | + goForwardSafe() |
| 205 | + turtle.turnLeft() |
| 206 | + goForwardSafe() |
| 207 | + turtle.turnLeft() |
| 208 | + turtle.turnLeft() |
210 | 209 | end
|
211 | 210 |
|
212 | 211 | resupply()
|
213 | 212 | newFloor(0)
|
214 | 213 | for i=1,build_height do
|
215 |
| - resupply() |
216 |
| - goUpSafe() |
217 |
| - doPlaceDown(support_slot) |
218 |
| - newFloor(i) |
| 214 | + resupply() |
| 215 | + goUpSafe() |
| 216 | + doPlaceDown(support_slot) |
| 217 | + newFloor(i) |
219 | 218 | end
|
220 | 219 |
|
| 220 | +-- vim: set filetype=lua et sts=2 sw=2 ts=2 sr sta |
0 commit comments