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

Mining Turtle Program

Started by thelittleman10, 21 June 2014 - 06:09 PM
thelittleman10 #1
Posted 21 June 2014 - 08:09 PM
I want to make a program for the mining turtle which mines certain blocks.
For example say there was an iron ore that I knew was there, how could I get it to mine the ore, but ignore everything else?
I know I have to compare it to whatever is in the slot # but can't do anymore than this.
turtle.select(slot)
turtle.compare()
Turkey #2
Posted 22 June 2014 - 02:14 AM
You need to use an if statement. It would be something like this:

turtle.select (slot)
if turtle.compare() then
  mineIron()
else
  ignore()
end

Here, I'm also assuming you've written two functions, one to handle mining iron, and the other to handle ignoring whatever else you come across.
thelittleman10 #3
Posted 22 June 2014 - 12:06 PM
No I haven't wriiten the functions as I am very knew to this, and in the (slot) do I put the slot number?
Lignum #4
Posted 22 June 2014 - 12:54 PM
No I haven't wriiten the functions as I am very knew to this, and in the (slot) do I put the slot number?
Yes, you put in the number of the slot that has the iron ore in it.
thelittleman10 #5
Posted 22 June 2014 - 09:15 PM
What do i put for the functions then?
Bomb Bloke #6
Posted 23 June 2014 - 12:02 AM
That's not a simple question. Computer programs don't work via assumptions - you've got to specify exactly what you want to happen. "Dig out a quarry while searching for certain blocks and moving around them" is a complex command.

To make this work you're going to have to understand basic control structures. Ideally you'll work through at least the first six of these tutorials.

Start out by combining a loop with the commands in the turtle API to have the turtle dig a line of a given length. Then stick that inside a second loop - make it turn at the end of each lane and dig another, in order to mine out a square layer. That lot goes inside a third loop, at which point you're having the turtle descend between layers and bore down to bedrock.

Once all that is sorted out, then start to worry about comparing blocks (and pathfinding around them).