Posted 07 February 2013 - 08:05 PM
Here is the code.
Ok. I am writing this program to dig a branch mine for me with specified trunk length and branch length. I am just gettting started and the second 'for' loop is giving me problems. It appears to me that the second loop is exactly the same as the first other than the change from 'for z=1,length' to 'for x=1,length'. The program is not finished yet because I like to de-bug as I go instead of having lots of errors to deal with at the end. The code here is only to make the 3 high 2 wide <x> length main mine shaft. The loop I am having problems with is the loop that has the turtle return to its starting position. Thanks in advance for the help.
P.S. Line 35 is in bold.
Lyqyd. It was typed over from MC. Not pasted. You were right there was a typo in the line before the error. I didnt close my parenthesis. Thanks!
function fuel()
if turtle.getFuelLevel() <=20 then
turtle.select(16)
turtle.refuel(1)
end
end
--Program Start--
print("Length of trunk: ")
local length = read()
print("Length of branches: ")
local blength = read()
turtle.up()
for z=1,length do
fuel()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
end
fuel()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
for x=1,length do --OP pointed out this line in bold prior to me adding the code tags. -L
fuel()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
end
Ok. I am writing this program to dig a branch mine for me with specified trunk length and branch length. I am just gettting started and the second 'for' loop is giving me problems. It appears to me that the second loop is exactly the same as the first other than the change from 'for z=1,length' to 'for x=1,length'. The program is not finished yet because I like to de-bug as I go instead of having lots of errors to deal with at the end. The code here is only to make the 3 high 2 wide <x> length main mine shaft. The loop I am having problems with is the loop that has the turtle return to its starting position. Thanks in advance for the help.
P.S. Line 35 is in bold.
Lyqyd. It was typed over from MC. Not pasted. You were right there was a typo in the line before the error. I didnt close my parenthesis. Thanks!
Edited by