CC to do - Mining a hall
How can I make a turtle mine and move? That's the question I was asking myself when I started this project. That wasn't even the hardest part but it is very important.
In this post I show you how I got to the point where I can make the turtle mine 2 wide 4 high 13 long mining hall for me. A goal kind of difficult for someone with no experience but easy enough that I could still succeed.
![]() |
| The mining turtle busy doing half of the hall (the file size made me shorten the gif sorry xd) |
So, how did I do it? Well, I started out very basic. If you read my previous posts (which you might have to for a little context) I started out using the basic commands. I first wanted to make the turtle mine and move forward. That's not too hard. I can do that by writing this.
turtle.dig()
turtle.forward()
Ad nauseam but..... that's kind of a lot of repeating the same thing over and over again. There had to be a different way to do it right? To find this out I did what any student would do and ask the (sort of) all knowing language model ChatGPT how I could make it more efficient.
ChatGPT taught me with all its grace about loops in lua. It showed me that by using this code:
for a = 1, 13 do
turtle.dig()
turtle.forward()
end
I could get a turtle to dig and move forward 13 times without having to write down 26 lines of just turtle.dig() and forward(). You can imagine my joy when I learned about this. This is basically what I used here the entire time but also what I will be using throughout the rest of the project. Thanks GPT :)
Now that we learned about loops lets see what I want to let the turtle do.
- Dig once and move forward
- Mine and move upwards 3 times
- Go down 3 times
- repeat the previous 3 points 13 times
- Go back to its original starting position
- Turn left once
- Move forward once
- Turn right once
- repeat the other actions again 13 times
Dig once and move forward
turtle.dig()
turtle.foward()Mine and move upwards 3 times
for a = 1, 3 do
turtle.digUp()
turtle.up()
end
Go down 3 times
for b = 1, 3 do
turtle.down()
end
Repeat this 13 times
for c = 1, 13 do
turtle.dig()
turtle.forward()
for a = 1, 3 do
turtle.digUp()
turtle.up()
end
for b = 1, 3 do
turtle.down()
end
end
Go back to its original starting position
for d = 1, 13 do
turtle.back()
end
Orienting for the other 50% of the hall
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
for c = 1, 13 do
turtle.dig()
turtle.forward()
for a = 1, 3 do
turtle.digUp()
turtle.up()
end
for b = 1, 3 do
turtle.down()
end
end
for d = 1, 13 do
turtle.back()
end
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
for g = 1, 13 do
turtle.dig()
turtle.forward()
for e = 1, 3 do
turtle.digUp()
turtle.up()
end
for f = 1, 3 do
turtle.down()
end
end
for h = 1, 13 do
turtle.back()
end

Comments
Post a Comment