Posted 14 October 2012 - 04:47 PM
                If I have a deep hole in the ground and want to fill it, I just stick a block (like glass) on top of it and then place the turtle 1 block in front of the hole. I run the "fill" program and it moves forward, digs out the spot under it, goes down as far as it can, and then fills the hole … ending where it started.
The program works as intended.
But I would like it to fill the hole, whether or not there is glass over the hole or not. There may be… there may not be. I want it to work either way.
As it stands now, When there is glass/a-block on top of the hole, it works perfectly. If there is not, It fills the hole but ends 1 layer too low.
As you can see later on in the code, I tried to fix it. I DIMmed out a section of the code and put replacement code above it. But the fix has no effect.
Help ?
                
            The program works as intended.
But I would like it to fill the hole, whether or not there is glass over the hole or not. There may be… there may not be. I want it to work either way.
As it stands now, When there is glass/a-block on top of the hole, it works perfectly. If there is not, It fills the hole but ends 1 layer too low.
As you can see later on in the code, I tried to fix it. I DIMmed out a section of the code and put replacement code above it. But the fix has no effect.
Help ?
--[[ Program name : fill
	  This program moves 1 forward then
	   moves down to lowest open space and then
	   fills with dirt/etc back up to where it started
	  --]]
--[[ Be sure the turtles has the following items
	  in the correct slots...
	    slot 13 has 64 coal/charcoal
	    other slots (at least 1) has filler (dirt/etc)
	  --]]
function refuel()
  fuellvl = turtle.getFuelLevel()
  if fuellvl<100 then
    amtchar = turtle.getItemCount(13)
    if amtchar > 1 then
	  turtle.select(13)
	  turtle.refuel(2)
	  turtle.select(1)
    else
	  if amtchar > 0 then
	    turtle.select(13)
	    turtle.refuel(1)
	    turtle.select(1)
	  end
    end
  end
end
--[[ set numeric var's --]]
fuellvl = 0
amtchar = 0
downMoves = 0
X = 0
fillSlot = 1
--[[ move forward one --]]
refuel()
turtle.forward()
--[[ for first move, it might have to dig through something
	   as I may have sealed a deep hole --]]
if not turtle.down() then
  turtle.digDown()
end
--[[ THIS SECTION IS THE OLD WAY AND IS DIMMED
if turtle.down() == false then
  turtle.digDown()
end
--]]
--[[ move down as far as it can --]]
while not turtle.detectDown() do
  refuel()
  turtle.down()
  downMoves = downMoves + 1
end
--[[ move up and fill --]]
while downMoves > 0 do
  refuel()
  turtle.up()
  while not turtle.placeDown() do
    fillSlot = fillSlot + 1
    if fillSlot == 13 then
	  fillSlot = 14
    end
    turtle.select(fillSlot)
  end
  downMoves = downMoves - 1
end
 
        