Im having an issue with my mining turtle code. Here's my code
function mine ()
done = false
while not done do
print("Moving to desired starting height...")
while not (TURTLE_POSITION.y == heightToStart) do
turtle.digDown()
turtle.down()
end
print("Starting height reached. Filtering Items...")
filterItems()
print("Filtered Items. Starting to mine cuboid...")
done = true
end
end
The problem is that the turtle keeps diging down no matter what. It doesn't stop until it reaches bedrock level.
EDIT: The code for the TURTLE_POSITION
function locateTurtle ()
print("Attempting to get location")
location = vector.new(gps.locate(5))
if not location.x then
print("Couldn't get location")
error()
end
print("Found location")
return location
end
refuelTurtle(calculateFuelUsage(cuboidX, cuboidY, cuboidZ))
local TURTLE_POSITION = locateTurtle()
So by the comments I received it was a simple problem: I forgot to update the turtle's position variable
My code now
function mine ()
done = false
while not done do
print("Moving to desired starting height...")
while not (TURTLE_POSITION.y == heightToStart) do
turtle.digDown()
turtle.down()
TURTLE_POSITION = locateTurtle()
end
print("Starting height reached. Filtering Items...")
filterItems()
print("Filtered Items. Starting to mine cuboid...")
done = true
end
end
function locateTurtle ()
print("Attempting to get location")
location = vector.new(gps.locate(5))
if not location.x then
print("Couldn't get location")
error()
end
print("Found location")
return location
end