Now my problem is when it reaches the set distance for Z which is the amount of rows, it just keeps digging more
rows! I have a check in place to see if the curZ == setZbut the turtle seems to ignore it and keep going...I'm unsure
on how to proceed with this piece of code.
local distY = 0
local distX = 0
local distZ
local fuel = 0
local fuelNeeded = 0
local curFuel = 0
function boot()
local turtleName
if os.getComputerLabel ~= "Mining" then
os.setComputerLabel("Mining")
else
end
size()
mining()
end
function size()
print("How big do you want the hole?")
write("Enter width: ")
distX = tonumber(read())
write("Enter length: ")
distZ = tonumber(read())
write("Enter depth: ")
distY = tonumber(read())
check()
end
function check()
local choice
write("You chose a size that was " ..distX.. " x " ..distZ.. " x " ..distY.. " big. Do you wish to change your choice? Y/N ")
choice = read()
if choice == "Y" then
size()
else
end
fuelCalc()
end
function invCheck()
end
function fuelCalc()
fuelNeeded = (distX*distZ*distY)+(distY)
fuel = math.ceil(80/fuelNeeded)
end
function mining()
local curDistX = 1
local curDistY = 0
local curDistZ = 1
curFuel = turtle.getFuelLevel()
while curFuel < fuelNeeded do
print("Not enough fuel, add " ..fuel.. " fuel units to the last slot.")
turtle.select(16)
turtle.refuel()
curFuel = turtle.getFuelLevel()
sleep(2)
end
turtle.select(1)
--mostly here
while curDistY ~= distY do
while curDistZ <= distZ do
if curDistZ == distZ then
if distZ % 2 == 0 then
turtle.turnRight()
for i=1,distZ do
turtle.forward()
end
turtle.turnRight()
print("I go back to the start!")
curDistZ = 0
else
turtle.turnLeft()
for j=1,distZ do
turtle.forward()
end
turtle.turnLeft()
print("I go back to the start!")
curDistZ = 0
end
turtle.digDown()
turtle.down()
print("I went down!")
curDistZ = 1
curDistY = curDistY + 1
end
--to here
while curDistX ~= distX do
turtle.dig()
turtle.forward()
print("I went forward!")
curDistX = curDistX + 1
if curDistX == distX then
if curDistZ % 2 == 0 then
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
print("I turned right!")
curDistX = 1
curDistZ = curDistZ + 1
else
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
print("I turned left!")
curDistX = 1
curDistZ = curDistZ + 1
end
else
end
end
end
end
end
boot()











