Posted 03 November 2013 - 12:17 PM
This works like excavate, but allows you specify all dimensions (including height), and doesn't waste fuel coming up to origin by using ender chests (from the ender storage mod) or a tesseract instead.
Usage: dig [length] [width] [height] [-f]
Put an ender chest in the first slot.
It will check to see if you have enough fuel and reject your attempts to start it if you don't have enough. If you think it is wrong or want it go start anyway, append '-f' to the command.
It's inspired by deFENCE_'s rendition, but uses about half the fuel, and half the time (doesn't re-traverse each row), and won't be offset by gravel.
Video
[media]http://youtu.be/MusAJVBRShE[/media]
Code - http://pastebin.com/urvJWGnu
Download
Usage: dig [length] [width] [height] [-f]
Put an ender chest in the first slot.
It will check to see if you have enough fuel and reject your attempts to start it if you don't have enough. If you think it is wrong or want it go start anyway, append '-f' to the command.
It's inspired by deFENCE_'s rendition, but uses about half the fuel, and half the time (doesn't re-traverse each row), and won't be offset by gravel.
Video
[media]http://youtu.be/MusAJVBRShE[/media]
Code - http://pastebin.com/urvJWGnu
Spoiler
-- Build Tools
-- dig v1
local args = { ... }
if args[1] == nil or args[2] == nil or args[3] == nil or turtle.getItemCount(1) < 1 or args[1] == "help" then
print ("Usage: dig [forward length] [right length] [depth]")
print ("Put an ender chest in the first slot")
return
end
local tilt = 0
local flength = tonumber(args[1])
local rlength = tonumber(args[2])
local depth = tonumber(args[3])
local blocks = rlength * flength * depth
if turtle.getFuelLevel() < blocks + rlength + flength + depth and args[4] ~= "-f" then
print ("You do not have enough fuel. This job needs ", fuelreq, " fuel.")
print ("Add more fuel, or append -f to dig anyway.")
return
end
function step()
while not turtle.forward() do
turtle.dig()
end
end
function stepUp()
while not turtle.up() do
turtle.digUp()
end
end
function stepDown()
while not turtle.down() do
turtle.digDown()
end
end
function placeUp()
while not turtle.placeUp() do
turtle.digUp()
end
end
function rotateRight()
turtle.turnRight()
if vertical then
stepUp()
else
step()
end
turtle.turnRight()
end
function rotateLeft()
turtle.turnLeft()
if vertical then
stepUp()
else
step()
end
turtle.turnLeft()
end
-- Dump inventory into ender chest.
function dump()
turtle.select(1)
placeUp()
for m = 2, 16, 1 do
turtle.select(m)
turtle.dropUp()
end
turtle.select(1)
turtle.digUp()
end
-- Dig em up.
for i = 1, depth, 1 do
for j = 1, rlength, 1 do
for k = 1, flength, 1 do
if turtle.getItemCount(16) > 1 then
dump()
end
turtle.digDown()
if k < flength then
step()
end
end
if j < rlength then
if (j + tilt) % 2 ~= 0 then
rotateRight()
else
rotateLeft()
end
end
end
if rlength % 2 == 0 and i % 2 ~= 0 then
tilt = 1
else
tilt = 0
end
turtle.turnRight()
turtle.turnRight()
stepDown()
end
-- Raise to initial height.
for i = 1, depth, 1 do
stepUp()
end
-- Return to origin.
if depth % 2 ~= 0 then
if rlength % 2 == 0 then
turtle.turnLeft()
for i = 1, rlength - 1, 1 do
step()
end
else
turtle.turnRight()
for i = 1, rlength - 1, 1 do
step()
end
turtle.turnLeft()
for i = 1, flength - 1, 1 do
step()
end
end
end
Download
pastebin get urvJWGnu dig