This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MmPMSFmM's profile picture

Branch Mining Script - Refueling Troubles

Started by MmPMSFmM, 15 July 2013 - 04:00 AM
MmPMSFmM #1
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?
Lyqyd #2
Posted 15 July 2013 - 01:06 PM
Split into new topic.