[英]ComputerCraft mining turtle doesn't stop diging down
我的采礦龜代碼有問題。 這是我的代碼
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()
所以根據我收到的評論,這是一個簡單的問題:我忘記更新海龜的 position 變量
我現在的代碼
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.