Posted 24 December 2012 - 10:29 AM
Hey,
So I'm really new to computercraft and I'm using it in Feed The Beast. Basically, I'm trying to write a turtle program that will allow me to specify the dimensions of a tunnel and have the turtle dig it. The variable d is for the length of the tunnel (distance), the variable h is for the height of the tunnel, and the variable w is for the width of the tunnel. Any input on how to make it work would be much appreciated! My current problem is when I run the program, the input screen for distance, width and height comes up, I put in the values I want, and then the turtle takes off in one direction and just keeps digging. :(/>
So I'm really new to computercraft and I'm using it in Feed The Beast. Basically, I'm trying to write a turtle program that will allow me to specify the dimensions of a tunnel and have the turtle dig it. The variable d is for the length of the tunnel (distance), the variable h is for the height of the tunnel, and the variable w is for the width of the tunnel. Any input on how to make it work would be much appreciated! My current problem is when I run the program, the input screen for distance, width and height comes up, I put in the values I want, and then the turtle takes off in one direction and just keeps digging. :(/>
--- Dimensional Input ---
term.clear()
textutils.slowPrint("Distance?")
local d=io.read()
d=tonumber(d)
textutils.slowPrint("Height?")
local h=io.read()
h=tonumber(h)
textutils.slowPrint("Width?")
local w=io.read()
w=tonumber(w)
--- Feedback ---
term.clear()
print("Digging a tunnel that is")
print((w)," blocks wide,")
print((h)," blocks tall,")
print("and ",(d)," blocks long")
--- Digging ---
while d > 0 do
turtle.select(1)
turtle.refuel(64)
turtle.dig()
turtle.forward()
--- Width ---
function width(w)
local e = w
if e > 1 then do
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnLeft()
e = e - 1
end
width(w)
turtle.turnLeft()
turtle.forward(w)
turtle.turnRight()
end
--- Height ---
Functionname=height()
local j = h
if j > 1 then do
turtle.digup()
turtle.up()
j = j - 1
end
turtle.down(h)
end
local e = w
if e > 1 then do
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
height()
turtle.down(h)
e = e - 1
end
turtle.turnLeft()
turtle.forward(w)
turtle.turnRight()
end
d = d - 1
end
end