Posted 04 May 2012 - 05:50 AM
Ok, so it works almost how I want it to so far. You place it, and enter the arguments and it's off! However, when I was testing with tunnels of width 3, it would finish the third width, and then turn as if to make the next width of the tunnel. Somehow, if x==w where x,w are both 3, is not returning true. I am absolutely baffled. It should simply finish the third width and back up to the entrance to the tunnel (if it's a really long tunnel you shouldn't have to go fetch it).
Perhaps it's an obvious oversight, but I cannot see it for the life of me.
On a completely unrelated note, suggestions how to implement the torch feature would be a appreciated, as well as any other advice.
Perhaps it's an obvious oversight, but I cannot see it for the life of me.
On a completely unrelated note, suggestions how to implement the torch feature would be a appreciated, as well as any other advice.
local arg = { ... }
function usage ()
print("Usage: tunnel <length> [options]\n\t<length> - length of tunnel\n\t<width> - width of tunnel, default 1\nt\t<height> - height of tunnel default 3\n\t<torchInterval> - blocks between torches, \n\t\tdefault 8, 0 is no torches")
end
function down(height, length)
for z=1, length do
while not turtle.forward() do
turtle.dig()
end
for a=1,height-1 do
while not turtle.up() do
turtle.digUp()
end
end
for b=1,height-1 do
turtle.down()
end
end
end
w = 1
h = 3
t = 8
if #arg==1 then
l = arg[1]
elseif #arg==2 then
l = arg[1]
w = arg[2]
elseif #arg==3 then
l = arg[1]
w = arg[2]
h = arg[3]
elseif #arg==4 then
l = arg[1]
w = arg[2]
h = arg[3]
t = arg[4]
else
usage()
return 0
end
for x=1,w do
print(x.." == "..w)
down(h,l)
if x==w then
print(x.." == "..w.."!!!!")
if x%2==0 then
print("gothere")
return 0
else
print("wrf")
for y=1,l do
turtle.back()
end
return 0
end
else
print("turn")
if x%2==1 then
turtle.turnLeft()
else
turtle.turnRight()
end
while not turtle.forward() do turtle.dig() end
if x%2==1 then
turtle.turnLeft()
else
turtle.turnRight()
end
turtle.digUp()
turtle.up()
while turtle.detectUp() do
sleep(1)
turtle.digUp()
end
turtle.down()
end
end