Posted 17 October 2013 - 07:05 PM
I have made a simple digging program that will attempt to fetch a turtle location via GPS and if it fails asking the user for manual input of the Y coordinate. It then calculates (Y level - 10) how far it needs to mine until it hits lava layer and will place a water bucket so that you can jump down.
The turtle stops, spews out the "Unexpected Error" message I built into the program multiple times into the console and ends the program if it hits a cave midway and there is no block underneath it.
My code is available here:
pastebin get nKy2QuPX
or
Thanks for your help.
The turtle stops, spews out the "Unexpected Error" message I built into the program multiple times into the console and ends the program if it hits a cave midway and there is no block underneath it.
My code is available here:
pastebin get nKy2QuPX
or
Spoiler
local x, y, z = gps.locate()
if y == nil then
print("Unable to retrieve location via GPS.")
print("Please enter Y coordinate:")
y = io.read()
else
print("Successfully retrieved coordinates via GPS")
end
blocksdig = y -10
blocksdug = 0
print("Please place fuel in the first slot, and a water bucket in the last.")
print("Digging will commence in 5 seconds.")
sleep(5)
function checkFuel()
if turtle.getFuelLevel() <= 100 then
turtle.select(1)
turtle.refuel(1)
end
end
while blocksdig > blocksdug do
if turtle.detectDown() then
turtle.digDown()
turtle.down()
checkFuel()
else
turtle.down()
checkFuel()
end
blocksdug = blocksdug + 1
end
if blocksdig == blocksdug then
turtle.select(16)
turtle.up()
turtle.up()
turtle.placeDown()
end
print("Finished digging.")
Thanks for your help.