Posted 21 August 2015 - 05:22 PM
Hello! I've recently been trying to write a strip mining program for my turtle, but I've been running into the error stated in the title. I want the turtle to mine a distance predefined by the user. To accomplish this, I wrote the following code. Note that this isn't the full program, but specifically the error. I'll be happy to post the full program, while it may be incomplete, if necessary. (Also, I'm new at this so my code might be a little messy :mellow:/> )
The functions refuel() and torchRight() are unrelated but do exactly as they say, nothing fancy there. The function stripmine2() is what does the actual mining and every time it runs it adds to x. x is the distance the turtle has gone from its original location, and the second repeat is to return it there. The error is in the line with tonumber(branch), where branch is a predefined user input that was already established using this code:
Where have I done wrong, or how can I get this working? Will post more if necessary. Thanks!
function mine()
repeat
refuel()
stripmine2()
stripmine2()
stripmine2()
stripmine2()
torchRight()
until
x >= tonumber(branch)
repeat
turtle.back()
x = x - 1
until
x == 0
end
The functions refuel() and torchRight() are unrelated but do exactly as they say, nothing fancy there. The function stripmine2() is what does the actual mining and every time it runs it adds to x. x is the distance the turtle has gone from its original location, and the second repeat is to return it there. The error is in the line with tonumber(branch), where branch is a predefined user input that was already established using this code:
print("Designate 'branch' distance")
local branch = read()
term.clear()
print("Are these parameters correct? Trunk Distance: " , trunk , " Branch Distance: " , branch)
Where have I done wrong, or how can I get this working? Will post more if necessary. Thanks!