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

ComputerCraft Mining Turtle Gravel check ideas?

Started by husplante, 03 July 2014 - 11:18 AM
husplante #1
Posted 03 July 2014 - 01:18 PM
Does anyone have a good idea of how i can improve this program so it will detect gravel and mine it out?
Btw This is my first program and i am only 12 so please dont do something super complicated.
:)/>
  • function turn180()
  • turtle.turnLeft()
  • turtle.turnLeft()
  • end
  • function up2()
  • turtle.up()
  • turtle.up()
  • end
  • function forward2()
  • turtle.forward()
  • turtle.forward()
  • end
  • function Dig3x3()
  • turtle.dig()
  • turtle.forward()
  • turtle.turnLeft()
  • turtle.dig()
  • turtle.digDown()
  • turtle.forward()
  • turtle.dig()
  • turtle.digDown()
  • turtle.down()
  • turtle.dig()
  • turtle.digDown()
  • turtle.forward()
  • turtle.digDown()
  • turn180()
  • forward2()
  • turtle.turnLeft()
  • turtle.digDown()
  • up2()
  • end
  • while turtle.getFuelLevel() ~= 0 and turtle.getItemCount(2) ~= 0 and turtle.getItemCount(16) ~= 1 do
  • Dig3x3()
  • Dig3x3()
  • Dig3x3()
  • Dig3x3()
  • Dig3x3()
  • turn180()
  • turtle.forward()
  • turtle.turnLeft()
  • turn180()
  • turtle.forward()
  • turn180()
  • turtle.select(2)
  • turtle.place(2)
  • turtle.turnLeft()
  • turtle.forward()
  • turtle.turnRight()
  • turtle.forward()
  • turtle.turnLeft()
  • end
GamerNebulae #2
Posted 03 July 2014 - 02:34 PM
First of all, since you are new on the forums, always paste code in between the [.CODE] tags (without the dots). I made a branching program a long time ago and it still works fine. This is how it runs (assuming that you want it to wait when gravel falls down):

function notMoving()
	    while not turtle.forward() do
			    turtle.dig()
			    sleep(1)
	    end
end

While it cannot move forwards, it will dig in front of himself and he will then wait. If he cannot move again, then he will repeat the same thing over and over and over again.
Edited on 03 July 2014 - 12:36 PM
husplante #3
Posted 03 July 2014 - 05:50 PM
Ty
husplante #4
Posted 03 July 2014 - 06:16 PM
IM just wondering why do you have 2 end lines?
Cranium #5
Posted 03 July 2014 - 06:22 PM
He's ending the function statement, and ending the while loop.
husplante #6
Posted 03 July 2014 - 07:15 PM
so i should do
if turtle.forward == false do
notMoving()

right?
husplante #7
Posted 03 July 2014 - 07:55 PM
Thank You for the help i made this now for my stripmine program thanks to what you teached me:)
[.Code]
function detectUp()
if turtle.detectUp() == true then
turtle.digUp()
sleep(1)
end
end

function Dig3x1()
turtle.dig()
if turtle.forward() == false then
turtle.dig()
sleep(1)
end
turtle.digUp()
detectUp()
turtle.digDown()
end

Dig3x1()
Dig3x1()
Dig3x1()
Dig3x1()
Dig3x1()
turtle.select(1)
turtle.placeDown()
GamerNebulae #8
Posted 03 July 2014 - 09:05 PM
-snip-

Just to shorten the code, I always use the keyword "not". It basically means "false". Example:

statement = false
if (not statement) then
  print("Statement was "..statement)
end
--#Output: Statement was false

The problem with your code at the moment is, it will run into a piece of gravel and if the stack of gravel is higher than 2, then it will not work. So please just use my code, otherwise it will not work.