我的挖掘海龟代码有问题。这是我的代码
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
问题是,无论发生什么,乌龟都会一直往下看。它不会停止,直到它达到基岩水平。
编辑: 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))
本地TURTLE_POSITION = locateTurtle()
发布于 2020-12-09 06:14:14
因此,根据我收到的评论,这是一个简单的问题:我忘记更新海龟的位置变量
我的代码现在
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
https://stackoverflow.com/questions/65207026
复制相似问题