Posted 15 July 2013 - 06:00 AM
Ok, so I made the following code for branch mining:
local function tRefuel()
if turtle.getFuelLevel() == 0 then
local function aRefuel()
for i=1,16 do
if turtle.getItemCount(i) > 0 then
turtle.select(i)
if turtle.refuel( 1 ) then
return true
end
end
end
if not aRefuel() then
print( "Add more fuel to continue." )
while not aRefuel() do
sleep( 1 )
end
print( "Resuming Branch." )
end
end
end
end
local function dUp()
if turtle.detectUp() then
tRefuel()
turtle.digUp()
tRefuel()
end
end
local function mdForward()
if turtle.detect() then
tRefuel()
turtle.dig()
turtle.forward()
dUp()
tRefuel()
end
end
local function dRoadA()
mdForward()
turtle.turnLeft()
mdForward()
turtle.turnRight()
mdForward()
turtle.turnRight()
mdForward()
turtle.turnLeft()
end
local function dRoadB()
mdForward()
turtle.turnRight()
mdForward()
turtle.turnLeft()
mdForward()
turtle.turnLeft()
mdForward()
turtle.turnRight()
end
local function dBranch()
mdForward()
mdForward()
mdForward()
mdForward()
mdForward()
end
local function dBranchA()
mdForward()
turtle.turnRight()
dBranch()
turtle.turnRight()
turtle.turnRight()
dBranch()
mdForward()
dBranch()
turtle.turnRight()
turtle.turnRight()
dBranch()
turtle.turnLeft()
end
local function dBranchB()
mdForward()
turtle.turnLeft()
dBranch()
turtle.turnLeft()
turtle.turnLeft()
dBranch()
mdForward()
dBranch()
turtle.turnLeft()
turtle.turnLeft()
dBranch()
turtle.turnRight()
end
local function bMining()
dRoadA()
dBranchA()
dRoadB()
dBranchB()
end
bMining()
bMining()
bMining()
bMining()
bMining()
bMining()
bMining()
bMining()
bMining()
bMining()
But every time I run it it ignores the refuelling commands. Does anyone know why this happens and how I can solve it?