SHOW:
|
|
- or go back to the newest paste.
| 1 | local tArgs = { ... }
| |
| 2 | - | local tArgs = { ... }
|
| 2 | + | if #tArgs ~= 2 then |
| 3 | - | if #tArgs ~= 1 then |
| 3 | + | print( "Usage: excavate <diameter> <depth>" ) |
| 4 | - | print( "Usage: excavate <diameter>" ) |
| 4 | + | return |
| 5 | - | return |
| 5 | + | end |
| 6 | - | end |
| 6 | + | |
| 7 | -- Mine in a quarry pattern until we hit something we can't dig | |
| 8 | - | -- Mine in a quarry pattern until we hit something we can't dig |
| 8 | + | local size = tonumber( tArgs[1] ) |
| 9 | - | local size = tonumber( tArgs[1] ) |
| 9 | + | if size < 1 then |
| 10 | - | if size < 1 then |
| 10 | + | print( "Excavate diameter must be positive" ) |
| 11 | - | print( "Excavate diameter must be positive" ) |
| 11 | + | return |
| 12 | - | return |
| 12 | + | end |
| 13 | - | end |
| 13 | + | |
| 14 | - | |
| 14 | + | local depth2 = tonumber( tArgs[2] ) |
| 15 | - | local depth = 0 |
| 15 | + | if depth2 < 1 then |
| 16 | - | local unloaded = 0 |
| 16 | + | print( "Excavate depth must be positive" ) |
| 17 | - | local collected = 0 |
| 17 | + | return |
| 18 | end | |
| 19 | - | local xPos,zPos = 0,0 |
| 19 | + | |
| 20 | - | local xDir,zDir = 0,1 |
| 20 | + | local depth = 0 |
| 21 | local unloaded = 0 | |
| 22 | - | local goTo -- Filled in further down |
| 22 | + | local collected = 0 |
| 23 | - | local refuel -- Filled in further down |
| 23 | + | |
| 24 | - | |
| 24 | + | local xPos,zPos = 0,0 |
| 25 | - | local function unload( _bKeepOneFuelStack ) |
| 25 | + | local xDir,zDir = 0,1 |
| 26 | - | print( "Unloading items..." ) |
| 26 | + | |
| 27 | - | for n=1,16 do |
| 27 | + | local goTo -- Filled in further down |
| 28 | - | local nCount = turtle.getItemCount(n) |
| 28 | + | local refuel -- Filled in further down |
| 29 | - | if nCount > 0 then |
| 29 | + | |
| 30 | - | turtle.select(n) |
| 30 | + | local function unload( _bKeepOneFuelStack ) |
| 31 | - | local bDrop = true |
| 31 | + | print( "Unloading items..." ) |
| 32 | - | if _bKeepOneFuelStack and turtle.refuel(0) then |
| 32 | + | for n=1,16 do |
| 33 | - | bDrop = false |
| 33 | + | local nCount = turtle.getItemCount(n) |
| 34 | - | _bKeepOneFuelStack = false |
| 34 | + | if nCount > 0 then |
| 35 | - | end |
| 35 | + | turtle.select(n) |
| 36 | - | if bDrop then |
| 36 | + | local bDrop = true |
| 37 | - | turtle.drop() |
| 37 | + | if _bKeepOneFuelStack and turtle.refuel(0) then |
| 38 | - | unloaded = unloaded + nCount |
| 38 | + | bDrop = false |
| 39 | - | end |
| 39 | + | _bKeepOneFuelStack = false |
| 40 | - | end |
| 40 | + | end |
| 41 | - | end |
| 41 | + | if bDrop then |
| 42 | - | collected = 0 |
| 42 | + | turtle.drop() |
| 43 | - | turtle.select(1) |
| 43 | + | unloaded = unloaded + nCount |
| 44 | - | end |
| 44 | + | end |
| 45 | end | |
| 46 | - | local function returnSupplies() |
| 46 | + | end |
| 47 | - | local x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir |
| 47 | + | collected = 0 |
| 48 | - | print( "Returning to surface..." ) |
| 48 | + | turtle.select(1) |
| 49 | - | goTo( 0,0,0,0,-1 ) |
| 49 | + | end |
| 50 | - | |
| 50 | + | |
| 51 | - | local fuelNeeded = 2*(x+y+z) + 1 |
| 51 | + | local function returnSupplies() |
| 52 | - | if not refuel( fuelNeeded ) then |
| 52 | + | local x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir |
| 53 | - | unload( true ) |
| 53 | + | print( "Returning to surface..." ) |
| 54 | - | print( "Waiting for fuel" ) |
| 54 | + | goTo( 0,0,0,0,-1 ) |
| 55 | - | while not refuel( fuelNeeded ) do |
| 55 | + | |
| 56 | - | os.pullEvent( "turtle_inventory" ) |
| 56 | + | local fuelNeeded = 2*(x+y+z) + 1 |
| 57 | - | end |
| 57 | + | if not refuel( fuelNeeded ) then |
| 58 | - | else |
| 58 | + | unload( true ) |
| 59 | - | unload( true ) |
| 59 | + | print( "Waiting for fuel" ) |
| 60 | - | end |
| 60 | + | while not refuel( fuelNeeded ) do |
| 61 | - | |
| 61 | + | os.pullEvent( "turtle_inventory" ) |
| 62 | - | print( "Resuming mining..." ) |
| 62 | + | end |
| 63 | - | goTo( x,y,z,xd,zd ) |
| 63 | + | else |
| 64 | - | end |
| 64 | + | unload( true ) |
| 65 | end | |
| 66 | - | local function collect() |
| 66 | + | |
| 67 | - | local bFull = true |
| 67 | + | print( "Resuming mining..." ) |
| 68 | - | local nTotalItems = 0 |
| 68 | + | goTo( x,y,z,xd,zd ) |
| 69 | - | for n=1,16 do |
| 69 | + | end |
| 70 | - | local nCount = turtle.getItemCount(n) |
| 70 | + | |
| 71 | - | if nCount == 0 then |
| 71 | + | local function collect() |
| 72 | - | bFull = false |
| 72 | + | local bFull = true |
| 73 | - | end |
| 73 | + | local nTotalItems = 0 |
| 74 | - | nTotalItems = nTotalItems + nCount |
| 74 | + | for n=1,16 do |
| 75 | - | end |
| 75 | + | local nCount = turtle.getItemCount(n) |
| 76 | - | |
| 76 | + | if nCount == 0 then |
| 77 | - | if nTotalItems > collected then |
| 77 | + | bFull = false |
| 78 | - | collected = nTotalItems |
| 78 | + | end |
| 79 | - | if math.fmod(collected + unloaded, 50) == 0 then |
| 79 | + | nTotalItems = nTotalItems + nCount |
| 80 | - | print( "Mined "..(collected + unloaded).." items." ) |
| 80 | + | end |
| 81 | - | end |
| 81 | + | |
| 82 | - | end |
| 82 | + | if nTotalItems > collected then |
| 83 | - | |
| 83 | + | collected = nTotalItems |
| 84 | - | if bFull then |
| 84 | + | if math.fmod(collected + unloaded, 50) == 0 then |
| 85 | - | print( "No empty slots left." ) |
| 85 | + | print( "Mined "..(collected + unloaded).." items." ) |
| 86 | - | return false |
| 86 | + | end |
| 87 | - | end |
| 87 | + | end |
| 88 | - | return true |
| 88 | + | |
| 89 | - | end |
| 89 | + | if bFull then |
| 90 | print( "No empty slots left." ) | |
| 91 | - | function refuel( ammount ) |
| 91 | + | return false |
| 92 | - | local fuelLevel = turtle.getFuelLevel() |
| 92 | + | end |
| 93 | - | if fuelLevel == "unlimited" then |
| 93 | + | return true |
| 94 | - | return true |
| 94 | + | end |
| 95 | - | end |
| 95 | + | |
| 96 | - | |
| 96 | + | function refuel( ammount ) |
| 97 | - | local needed = ammount or (xPos + zPos + depth + 2) |
| 97 | + | local fuelLevel = turtle.getFuelLevel() |
| 98 | - | if turtle.getFuelLevel() < needed then |
| 98 | + | if fuelLevel == "unlimited" then |
| 99 | - | local fueled = false |
| 99 | + | return true |
| 100 | - | for n=1,16 do |
| 100 | + | end |
| 101 | - | if turtle.getItemCount(n) > 0 then |
| 101 | + | |
| 102 | - | turtle.select(n) |
| 102 | + | local needed = ammount or (xPos + zPos + depth + 2) |
| 103 | - | if turtle.refuel(1) then |
| 103 | + | if turtle.getFuelLevel() < needed then |
| 104 | - | while turtle.getItemCount(n) > 0 and turtle.getFuelLevel() < needed do |
| 104 | + | local fueled = false |
| 105 | - | turtle.refuel(1) |
| 105 | + | for n=1,16 do |
| 106 | - | end |
| 106 | + | if turtle.getItemCount(n) > 0 then |
| 107 | - | if turtle.getFuelLevel() >= needed then |
| 107 | + | turtle.select(n) |
| 108 | - | turtle.select(1) |
| 108 | + | if turtle.refuel(1) then |
| 109 | - | return true |
| 109 | + | while turtle.getItemCount(n) > 0 and turtle.getFuelLevel() < needed do |
| 110 | - | end |
| 110 | + | turtle.refuel(1) |
| 111 | - | end |
| 111 | + | end |
| 112 | - | end |
| 112 | + | if turtle.getFuelLevel() >= needed then |
| 113 | - | end |
| 113 | + | turtle.select(1) |
| 114 | - | turtle.select(1) |
| 114 | + | return true |
| 115 | - | return false |
| 115 | + | end |
| 116 | - | end |
| 116 | + | end |
| 117 | - | |
| 117 | + | end |
| 118 | - | return true |
| 118 | + | end |
| 119 | - | end |
| 119 | + | turtle.select(1) |
| 120 | return false | |
| 121 | - | local function tryForwards() |
| 121 | + | end |
| 122 | - | if not refuel() then |
| 122 | + | |
| 123 | - | print( "Not enough Fuel" ) |
| 123 | + | return true |
| 124 | - | returnSupplies() |
| 124 | + | end |
| 125 | - | end |
| 125 | + | |
| 126 | - | |
| 126 | + | local function tryForwards() |
| 127 | - | while not turtle.forward() do |
| 127 | + | if not refuel() then |
| 128 | - | if turtle.detect() then |
| 128 | + | print( "Not enough Fuel" ) |
| 129 | - | if turtle.dig() then |
| 129 | + | returnSupplies() |
| 130 | - | if not collect() then |
| 130 | + | end |
| 131 | - | returnSupplies() |
| 131 | + | |
| 132 | - | end |
| 132 | + | while not turtle.forward() do |
| 133 | - | else |
| 133 | + | if turtle.detect() then |
| 134 | - | return false |
| 134 | + | if turtle.dig() then |
| 135 | - | end |
| 135 | + | if not collect() then |
| 136 | - | elseif turtle.attack() then |
| 136 | + | returnSupplies() |
| 137 | - | if not collect() then |
| 137 | + | end |
| 138 | - | returnSupplies() |
| 138 | + | else |
| 139 | - | end |
| 139 | + | return false |
| 140 | - | else |
| 140 | + | end |
| 141 | - | sleep( 0.5 ) |
| 141 | + | elseif turtle.attack() then |
| 142 | - | end |
| 142 | + | if not collect() then |
| 143 | - | end |
| 143 | + | returnSupplies() |
| 144 | - | |
| 144 | + | end |
| 145 | - | xPos = xPos + xDir |
| 145 | + | else |
| 146 | - | zPos = zPos + zDir |
| 146 | + | sleep( 0.5 ) |
| 147 | - | return true |
| 147 | + | end |
| 148 | - | end |
| 148 | + | end |
| 149 | ||
| 150 | - | local function tryDown() |
| 150 | + | xPos = xPos + xDir |
| 151 | - | if not refuel() then |
| 151 | + | zPos = zPos + zDir |
| 152 | - | print( "Not enough Fuel" ) |
| 152 | + | return true |
| 153 | - | returnSupplies() |
| 153 | + | end |
| 154 | - | end |
| 154 | + | |
| 155 | - | |
| 155 | + | local function tryDown() |
| 156 | - | while not turtle.down() do |
| 156 | + | if not refuel() then |
| 157 | - | if turtle.detectDown() then |
| 157 | + | print( "Not enough Fuel" ) |
| 158 | - | if turtle.digDown() then |
| 158 | + | returnSupplies() |
| 159 | - | if not collect() then |
| 159 | + | end |
| 160 | - | returnSupplies() |
| 160 | + | |
| 161 | - | end |
| 161 | + | while not turtle.down() do |
| 162 | - | else |
| 162 | + | if turtle.detectDown() then |
| 163 | - | return false |
| 163 | + | if turtle.digDown() then |
| 164 | - | end |
| 164 | + | if not collect() then |
| 165 | - | elseif turtle.attackDown() then |
| 165 | + | returnSupplies() |
| 166 | - | if not collect() then |
| 166 | + | end |
| 167 | - | returnSupplies() |
| 167 | + | else |
| 168 | - | end |
| 168 | + | return false |
| 169 | - | else |
| 169 | + | end |
| 170 | - | sleep( 0.5 ) |
| 170 | + | elseif turtle.attackDown() then |
| 171 | - | end |
| 171 | + | if not collect() then |
| 172 | - | end |
| 172 | + | returnSupplies() |
| 173 | end | |
| 174 | - | depth = depth + 1 |
| 174 | + | else |
| 175 | - | if math.fmod( depth, 10 ) == 0 then |
| 175 | + | sleep( 0.5 ) |
| 176 | - | print( "Descended "..depth.." metres." ) |
| 176 | + | end |
| 177 | - | end |
| 177 | + | end |
| 178 | ||
| 179 | - | return true |
| 179 | + | depth = depth + 1 |
| 180 | - | end |
| 180 | + | if math.fmod( depth, 10 ) == 0 then |
| 181 | print( "Descended "..depth.." metres." ) | |
| 182 | - | local function turnLeft() |
| 182 | + | end |
| 183 | - | turtle.turnLeft() |
| 183 | + | |
| 184 | - | xDir, zDir = -zDir, xDir |
| 184 | + | return true |
| 185 | - | end |
| 185 | + | end |
| 186 | ||
| 187 | - | local function turnRight() |
| 187 | + | local function turnLeft() |
| 188 | - | turtle.turnRight() |
| 188 | + | turtle.turnLeft() |
| 189 | - | xDir, zDir = zDir, -xDir |
| 189 | + | xDir, zDir = -zDir, xDir |
| 190 | - | end |
| 190 | + | end |
| 191 | ||
| 192 | - | function goTo( x, y, z, xd, zd ) |
| 192 | + | local function turnRight() |
| 193 | - | while depth > y do |
| 193 | + | turtle.turnRight() |
| 194 | - | if turtle.up() then |
| 194 | + | xDir, zDir = zDir, -xDir |
| 195 | - | depth = depth - 1 |
| 195 | + | end |
| 196 | - | elseif turtle.digUp() or turtle.attackUp() then |
| 196 | + | |
| 197 | - | collect() |
| 197 | + | function goTo( x, y, z, xd, zd ) |
| 198 | - | else |
| 198 | + | while depth > y do |
| 199 | - | sleep( 0.5 ) |
| 199 | + | if turtle.up() then |
| 200 | - | end |
| 200 | + | depth = depth - 1 |
| 201 | - | end |
| 201 | + | elseif turtle.digUp() or turtle.attackUp() then |
| 202 | collect() | |
| 203 | - | if xPos > x then |
| 203 | + | else |
| 204 | - | while xDir ~= -1 do |
| 204 | + | sleep( 0.5 ) |
| 205 | - | turnLeft() |
| 205 | + | end |
| 206 | - | end |
| 206 | + | end |
| 207 | - | while xPos > x do |
| 207 | + | |
| 208 | - | if turtle.forward() then |
| 208 | + | if xPos > x then |
| 209 | - | xPos = xPos - 1 |
| 209 | + | while xDir ~= -1 do |
| 210 | - | elseif turtle.dig() or turtle.attack() then |
| 210 | + | turnLeft() |
| 211 | - | collect() |
| 211 | + | end |
| 212 | - | else |
| 212 | + | while xPos > x do |
| 213 | - | sleep( 0.5 ) |
| 213 | + | if turtle.forward() then |
| 214 | - | end |
| 214 | + | xPos = xPos - 1 |
| 215 | - | end |
| 215 | + | elseif turtle.dig() or turtle.attack() then |
| 216 | - | elseif xPos < x then |
| 216 | + | collect() |
| 217 | - | while xDir ~= 1 do |
| 217 | + | else |
| 218 | - | turnLeft() |
| 218 | + | sleep( 0.5 ) |
| 219 | - | end |
| 219 | + | end |
| 220 | - | while xPos < x do |
| 220 | + | end |
| 221 | - | if turtle.forward() then |
| 221 | + | elseif xPos < x then |
| 222 | - | xPos = xPos + 1 |
| 222 | + | while xDir ~= 1 do |
| 223 | - | elseif turtle.dig() or turtle.attack() then |
| 223 | + | turnLeft() |
| 224 | - | collect() |
| 224 | + | end |
| 225 | - | else |
| 225 | + | while xPos < x do |
| 226 | - | sleep( 0.5 ) |
| 226 | + | if turtle.forward() then |
| 227 | - | end |
| 227 | + | xPos = xPos + 1 |
| 228 | - | end |
| 228 | + | elseif turtle.dig() or turtle.attack() then |
| 229 | - | end |
| 229 | + | collect() |
| 230 | - | |
| 230 | + | else |
| 231 | - | if zPos > z then |
| 231 | + | sleep( 0.5 ) |
| 232 | - | while zDir ~= -1 do |
| 232 | + | end |
| 233 | - | turnLeft() |
| 233 | + | end |
| 234 | - | end |
| 234 | + | end |
| 235 | - | while zPos > z do |
| 235 | + | |
| 236 | - | if turtle.forward() then |
| 236 | + | if zPos > z then |
| 237 | - | zPos = zPos - 1 |
| 237 | + | while zDir ~= -1 do |
| 238 | - | elseif turtle.dig() or turtle.attack() then |
| 238 | + | turnLeft() |
| 239 | - | collect() |
| 239 | + | end |
| 240 | - | else |
| 240 | + | while zPos > z do |
| 241 | - | sleep( 0.5 ) |
| 241 | + | if turtle.forward() then |
| 242 | - | end |
| 242 | + | zPos = zPos - 1 |
| 243 | - | end |
| 243 | + | elseif turtle.dig() or turtle.attack() then |
| 244 | - | elseif zPos < z then |
| 244 | + | collect() |
| 245 | - | while zDir ~= 1 do |
| 245 | + | else |
| 246 | - | turnLeft() |
| 246 | + | sleep( 0.5 ) |
| 247 | - | end |
| 247 | + | end |
| 248 | - | while zPos < z do |
| 248 | + | end |
| 249 | - | if turtle.forward() then |
| 249 | + | elseif zPos < z then |
| 250 | - | zPos = zPos + 1 |
| 250 | + | while zDir ~= 1 do |
| 251 | - | elseif turtle.dig() or turtle.attack() then |
| 251 | + | turnLeft() |
| 252 | - | collect() |
| 252 | + | end |
| 253 | - | else |
| 253 | + | while zPos < z do |
| 254 | - | sleep( 0.5 ) |
| 254 | + | if turtle.forward() then |
| 255 | - | end |
| 255 | + | zPos = zPos + 1 |
| 256 | - | end |
| 256 | + | elseif turtle.dig() or turtle.attack() then |
| 257 | - | end |
| 257 | + | collect() |
| 258 | - | |
| 258 | + | else |
| 259 | - | while depth < y do |
| 259 | + | sleep( 0.5 ) |
| 260 | - | if turtle.down() then |
| 260 | + | end |
| 261 | - | depth = depth + 1 |
| 261 | + | end |
| 262 | - | elseif turtle.digDown() or turtle.attackDown() then |
| 262 | + | end |
| 263 | - | collect() |
| 263 | + | |
| 264 | - | else |
| 264 | + | while depth < y do |
| 265 | - | sleep( 0.5 ) |
| 265 | + | if turtle.down() then |
| 266 | - | end |
| 266 | + | depth = depth + 1 |
| 267 | - | end |
| 267 | + | elseif turtle.digDown() or turtle.attackDown() then |
| 268 | - | |
| 268 | + | collect() |
| 269 | - | while zDir ~= zd or xDir ~= xd do |
| 269 | + | else |
| 270 | - | turnLeft() |
| 270 | + | sleep( 0.5 ) |
| 271 | - | end |
| 271 | + | end |
| 272 | - | end |
| 272 | + | end |
| 273 | ||
| 274 | - | if not refuel() then |
| 274 | + | while zDir ~= zd or xDir ~= xd do |
| 275 | - | print( "Out of Fuel" ) |
| 275 | + | turnLeft() |
| 276 | - | return |
| 276 | + | end |
| 277 | - | end |
| 277 | + | end |
| 278 | ||
| 279 | - | print( "Excavating..." ) |
| 279 | + | if not refuel() then |
| 280 | print( "Out of Fuel" ) | |
| 281 | - | local reseal = false |
| 281 | + | return |
| 282 | - | turtle.select(1) |
| 282 | + | end |
| 283 | - | if turtle.digDown() then |
| 283 | + | |
| 284 | - | reseal = true |
| 284 | + | print( "Excavating..." ) |
| 285 | - | end |
| 285 | + | |
| 286 | local reseal = false | |
| 287 | - | local alternate = 0 |
| 287 | + | turtle.select(1) |
| 288 | - | local done = false |
| 288 | + | if turtle.digDown() then |
| 289 | - | while not done do |
| 289 | + | reseal = true |
| 290 | - | for n=1,size do |
| 290 | + | end |
| 291 | - | for m=1,size-1 do |
| 291 | + | |
| 292 | - | if not tryForwards() then |
| 292 | + | local alternate = 0 |
| 293 | - | done = true |
| 293 | + | local done = false |
| 294 | - | break |
| 294 | + | while (depth < depth2) and (not done) do |
| 295 | - | end |
| 295 | + | for n=1,size do |
| 296 | - | end |
| 296 | + | for m=1,size-1 do |
| 297 | - | if done then |
| 297 | + | if not tryForwards() then |
| 298 | - | break |
| 298 | + | done = true |
| 299 | - | end |
| 299 | + | break |
| 300 | - | if n<size then |
| 300 | + | end |
| 301 | - | if math.fmod(n + alternate,2) == 0 then |
| 301 | + | end |
| 302 | - | turnLeft() |
| 302 | + | if done then |
| 303 | - | if not tryForwards() then |
| 303 | + | break |
| 304 | - | done = true |
| 304 | + | end |
| 305 | - | break |
| 305 | + | if n<size then |
| 306 | - | end |
| 306 | + | if math.fmod(n + alternate,2) == 0 then |
| 307 | - | turnLeft() |
| 307 | + | turnLeft() |
| 308 | - | else |
| 308 | + | if not tryForwards() then |
| 309 | - | turnRight() |
| 309 | + | done = true |
| 310 | - | if not tryForwards() then |
| 310 | + | break |
| 311 | - | done = true |
| 311 | + | end |
| 312 | - | break |
| 312 | + | turnLeft() |
| 313 | - | end |
| 313 | + | else |
| 314 | - | turnRight() |
| 314 | + | turnRight() |
| 315 | - | end |
| 315 | + | if not tryForwards() then |
| 316 | - | end |
| 316 | + | done = true |
| 317 | - | end |
| 317 | + | break |
| 318 | - | if done then |
| 318 | + | end |
| 319 | - | break |
| 319 | + | turnRight() |
| 320 | - | end |
| 320 | + | end |
| 321 | - | |
| 321 | + | end |
| 322 | - | if size > 1 then |
| 322 | + | end |
| 323 | - | if math.fmod(size,2) == 0 then |
| 323 | + | if done then |
| 324 | - | turnRight() |
| 324 | + | break |
| 325 | - | else |
| 325 | + | end |
| 326 | - | if alternate == 0 then |
| 326 | + | |
| 327 | - | turnLeft() |
| 327 | + | if size > 1 then |
| 328 | - | else |
| 328 | + | if math.fmod(size,2) == 0 then |
| 329 | - | turnRight() |
| 329 | + | turnRight() |
| 330 | - | end |
| 330 | + | else |
| 331 | - | alternate = 1 - alternate |
| 331 | + | if alternate == 0 then |
| 332 | - | end |
| 332 | + | turnLeft() |
| 333 | - | end |
| 333 | + | else |
| 334 | - | |
| 334 | + | turnRight() |
| 335 | - | if not tryDown() then |
| 335 | + | end |
| 336 | - | done = true |
| 336 | + | alternate = 1 - alternate |
| 337 | - | break |
| 337 | + | end |
| 338 | - | end |
| 338 | + | end |
| 339 | - | end |
| 339 | + | |
| 340 | if not tryDown() then | |
| 341 | - | print( "Returning to surface..." ) |
| 341 | + | done = true |
| 342 | break | |
| 343 | - | -- Return to where we started |
| 343 | + | end |
| 344 | - | goTo( 0,0,0,0,-1 ) |
| 344 | + | end |
| 345 | - | unload( false ) |
| 345 | + | |
| 346 | - | goTo( 0,0,0,0,1 ) |
| 346 | + | print( "Returning to surface..." ) |
| 347 | ||
| 348 | - | -- Seal the hole |
| 348 | + | -- Return to where we started |
| 349 | - | if reseal then |
| 349 | + | goTo( 0,0,0,0,-1 ) |
| 350 | - | turtle.placeDown() |
| 350 | + | unload( false ) |
| 351 | - | end |
| 351 | + | goTo( 0,0,0,0,1 ) |
| 352 | ||
| 353 | - | print( "Mined "..(collected + unloaded).." items total." ) |
| 353 | + | -- Seal the hole |
| 354 | if reseal then | |
| 355 | turtle.placeDown() | |
| 356 | end | |
| 357 | ||
| 358 | print( "Mined "..(collected + unloaded).." items total." ) |