Still new to programming and i appreciate if someone could tell me what's wrong with my code.
Spoiler
--Variables!
local miningLength = 50
local movingLength = 4
--Functions!
function dig()
while turtle.detect()do
turtle.dig()
sleep(1)
end
end
function digUp()
while turtle.detectUp()do
turtle.digUp()
sleep(1)
end
end
function turnRight2()
turtle.turnRight()
turtle.turnRight()
end
function turnLeft2()
turtle.turnLeft()
turtle.turnLeft()
end
function path()
if not turtle.detectDown() then
turtle.select(2)
turtle.placeDown()
end
end
--Program!
for i= 1,miningLength, 1 do
if turtle.getFuelLevel() <100 then
turtle.refuel(1)
print("Refuel!")
end
print("mining...")
dig()
turtle.forward()
turtle.turnLeft()
dig()
turnRight2()
dig()
digUp()
turtle.up()
dig()
turnLeft2()
dig()
digUp()
turtle.up()
dig()
turnRight2()
dig()
turtle.turnLeft()
turtle.down()
turtle.down()
path()
end
miningLength = 50
for i = 1,miningLength,1 do
turtle.back()
end
turtle.select(16)
turtle.placeUp()
sleep(1)
turtle.select(2)
turtle.dropUp()
turtle.select(3)
turtle.dropUp()
turtle.select(4)
turtle.dropUp()
turtle.select(5)
turtle.dropUp()
turtle.select(6)
turtle.dropUp()
turtle.select(7)
turtle.dropUp()
turtle.select(8)
turtle.dropUp()
turtle.select(9)
turtle.dropUp()
turtle.select(10)
turtle.dropUp()
turtle.select(11)
turtle.dropUp()
turtle.select(12)
turtle.dropUp()
turtle.select(13)
turtle.dropUp()
turtle.select(14)
turtle.dropUp()
turtle.select(15)
turtle.dropUp()
sleep(1)
turtle.select(16)
turtle.digUp()
print("Done")
sleep(1)
turtle.turnRight()
turtle.forward()
movingLength = 5
for i = 1,movingLength,1 do
dig()
turtle.turnLeft()
dig()
turnRight2()
dig()
digUp()
turtle.up()
dig()
turnLeft2()
dig()
digUp()
turtle.up()
dig()
turnRight2()
dig()
turtle.turnLeft()
turtle.down()
turtle.down()
path()
turtle.forward()
end
turtle.back()
turtle.turnLeft()
print("Ready to mine again.")