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

best way to deal with gravel!

Started by dutchnerd, 13 January 2013 - 08:34 PM
dutchnerd #1
Posted 13 January 2013 - 09:34 PM
i have maak a program for make a 3x3 tunnel.
only i cannot get a good gravel detect function for my program!
i want that the turtle detect gravel befor he forward en not mess up my count for the tunnel lengt.
and i.m not a good programmer.
and srry for my bad eng


n = 1
function dig()
dig1()
dig1()
dig1()
dig2()
end

function dig1()
turtle.dig()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.up()
end

function dig2()
turtle.down()
turtle.down()
turtle.forward()
end


function fuelCheck()
j = turtle.getFuelLevel()
turtle.getFuelLevel()
print("checking Fuel")

if  j >180 then
print("Fuel is good")

else
  print("Fuel is low! refueling")
  turtle.select(1)
  turtle.refuel(64)
end

end

function torch()
turtle.back()
turtle.up()
turtle.turnRight()
turtle.forward()
turtle.select(2)
turtle.placeUp()
turtle.back()
turtle.turnLeft()
turtle.down()
turtle.forward()
n = 1
end

print("fuel in slot1")
print("torch in slot2")
fuelCheck()
print("How far?")
dist = tonumber(read())
for i = 1, dist do
dig()
n = n + 1

  if n == 7 then
  torch()
  end
end
crazyguymgd #2
Posted 13 January 2013 - 09:42 PM
well first you have a moveforward function but you never actually call it. otherwise that is the basics of the moveforward function I use to avoid gravel problems.
theoriginalbit #3
Posted 13 January 2013 - 10:12 PM
read this… remiX and I answer this question

http://www.computercraft.info/forums2/index.php?/topic/8807-lua-question-quarry-whats-the-best-way-to-deal-with-gravel-for-my-program/

only additional thing i can add to this link to suit your situation is to increment the moved value AFTER the while loops from the above link…
detsuo04 #4
Posted 13 January 2013 - 11:03 PM
What i would do is mine forward sleep 2 detect forward, if the detect shows an object repeat. then only add tick to your length variable after a forward move.
I would write the code but im not sure entirely what it would be. sory im still a tad new
theoriginalbit #5
Posted 13 January 2013 - 11:24 PM
What i would do is mine forward sleep 2 detect forward, if the detect shows an object repeat. then only add tick to your length variable after a forward move.
I would write the code but im not sure entirely what it would be. sory im still a tad new
Sleeping only requires 0.4 seconds (the time it takes for a block to fall…